home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Commun⁄Network / Telnet 2.5.src.ThinkC / source / menu.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-27  |  89.7 KB  |  3,304 lines  |  [TEXT/MPS ]

  1. #ifdef lint
  2. static char *SCCSid = "%W%    (NCSA)    %G%";
  3. #endif
  4. /*
  5. *    menu.c
  6. *     by Gaige B. Paulsen
  7. ****************************************************************************
  8. *    Part of NCSA Telnet for the Macintosh                                   *
  9. *                                                                          *
  10. *      Uses    :                                                               *
  11. *      TCP/IP kernel for NCSA Telnet                                       *
  12. *      by Tim Krauskopf                                                    *
  13. *       with Macintosh code by Gaige B. Paulsen                                 *
  14. *                                                                          *
  15. *      National Center for Supercomputing Applications                     *
  16. *      152 Computing Applications Building                                 *
  17. *      605 E. Springfield Ave.                                             *
  18. *      Champaign, IL  61820                                                *
  19. *                                                                          *
  20. *                                                                          *
  21. ****************************************************************************
  22. *
  23. *    Menu Handling and initialization code.
  24. *
  25. *    Called by:
  26. *        event.c
  27. *        maclook.c
  28. */
  29.  
  30. /*
  31.  *    Files to be included in the compile
  32.  *
  33.  */
  34.  
  35. #include    <stdio.h>
  36. #include <stdlib.h>
  37. #include <string.h>
  38. #include <ctype.h>
  39.  
  40. #include    <Desk.h>
  41. #include    <Dialogs.h>
  42. #include    <Events.h>
  43. #include    <Fonts.h>
  44. #include    <Memory.h>
  45. #include    <Menus.h>
  46. #include    <OsUtils.h>
  47. #include    <Packages.h>
  48. #include     <Printing.h>
  49. #include    <Quickdraw.h>
  50. #include    <Scrap.h>
  51. #include    <ToolUtils.h>
  52. /*#include <Strings.h>            /* BYU LSC */
  53.  
  54. #include "alias.h"                /* NCSA: alias definitions */
  55. #include "protocol.h"
  56. #include    "wind.h"
  57. #include     "configrec.h"
  58.  
  59. #include    "hostform.h"
  60. #include    "prefs.h"
  61. #include "netevent.h"
  62. #include "dlayer.h"
  63. #include "util.h"
  64. #include "rsmac.h"
  65. #include "user.h"
  66. #include "maclook.h"
  67. #include "macutil.h"
  68. #include "vrrgmac.h"
  69. #include "rgmp.h"
  70. #include "tekrgmac.h"
  71. #include "vgtek.h"
  72. #include "vsinterf.h"
  73. #include "event.h"
  74. #include "config.h"
  75. #include "mactools.h"
  76. #include "confile.h"
  77.  
  78. #ifdef MPW
  79. #include "mpw.h"
  80. #endif MPW
  81.  
  82. /*
  83.  *    Resource Defines
  84.  */
  85.  
  86. /*----------------------------------------------------------------*/
  87. /* NCSA: these are the new defines for the alias code */
  88.  
  89. #define kListMods 0
  90.  
  91. #define AliasDLOG    130
  92. #define kAliasOutline    12
  93. #define kAliasHostItem    9
  94. #define kAliasPortItem    10
  95. #define kAliasAliasItem    11
  96. #define kAliasRemove    4
  97. #define kAliasCancel    2
  98. #define kAliasOK        1
  99. #define kAliasAdd        3
  100. #define kAliasList        13
  101. /*-----------------------------------------------------------------*/
  102.  
  103. #define    DLOGOk        1
  104. #define DLOGCancel    2
  105.  
  106. #define MacroDLOG    500        /* The Macros dialog */
  107. #define QuitDLOG    2010    /* The Quit Confirmation Dialog */
  108. #define    CloseDLOG    2001    /* The Close Confirmation Dialog */
  109.  
  110. #define    SessionDLOG    257        /* The Session initialization dialog ----------- */
  111. #define    Shost        5        /* The Destination field in GetDest dialog */
  112. #define Sname        7        /* Session name in session dialog */
  113. #define Sftponly    9        /* BYU - Indicates an FTP only session */
  114. #define Sserialonly    10        /* BYU 2.4.15 - Indicates a serial port session */
  115.  
  116. #define SConfigDLOG    260        /* The Session configuration dialog ------------ */
  117. #define    SChost        4        /* Put the session name here [STATIC]  */
  118. #define SCname        6        /* Session name in session dialog */
  119. #define SCwidth132    8        /* Session width is 132 */
  120. #define SCwidth80    9        /* Session width is 80 */
  121. #define SCkbbs        11        /* Keyboard Backspace default */
  122. #define SCkbdel        12        /* Keyboard Delete default */
  123. #define    SCscrolon    13        /* Session scrollback toggle */
  124. #define SCscrolnum    14        /* Session scrollback number of lines */
  125. #define    SCtekclear    17        /* Session Tek <esc> ^L clears screen */
  126. #define    SCtekcreate    18        /* Session Tek <esc> ^L creates new window */
  127. #define SCcrLF        20        /* Session cr translates to <cr><lf> */
  128. #define SCcrNUL        21        /* Session cr translates to <cr><nul> */
  129. #define SCechoBuff    23        /* Session echo mode buffers (local edit ) */
  130. #define SCechoSend    24        /* Session echo mode sends (half duplex ) */
  131. #define SCtekold    27        /* TEK 4014 emulation */
  132. #define SCteknew    28        /* TEK 4105 emulation */
  133. #define SClineY        30        /* Line mode on */                        /* BYU 2.4.9 */
  134. #define SClineN        31        /* Line mode off */                        /* BYU 2.4.9 */
  135. #define SCeightY    33        /* Eight bits of font displayed */        /* BYU 2.4.9 */
  136. #define SCeightN    34        /* Seven bits of font displayed */        /* BYU 2.4.9 */
  137.  
  138. #define    LinesDLOG    272        /* The number of lines config dialog ----------- */
  139. #define    LinesNumber    5        /* User given # of lines */
  140.  
  141. #define SetupDLOG   273     /*  Setup keys interface */
  142.  
  143. #define StatusDLOG    270        /* Inactive connection status dialog */
  144. #define BadDynDLOG    280        /* Bad Dynamic IP Number search */
  145.  
  146. #define PGRECT    (*prRecHdl)->prInfo.rPage        /* Macro for making the pagerect more accessible */
  147.  
  148.  
  149. /*
  150.  *    Defines for the menu handling code.
  151.  */
  152.  
  153. #define    appleMenu    1        /*    Apple Menu ID */
  154. #define    NfileMenu    512        /*    File Menu Resource ID */
  155. #define    NeditMenu    513        /*    Edit Menu Resource ID */
  156. #define NtermMenu    514        /*    Emulation Menu Resource ID */
  157. #define    NconnMenu    515        /*    Connection Menu Resource ID */
  158. #define NnetMenu    516        /*    Network Menu Resource ID */
  159.  
  160. #define    fileMenu    256        /*    File Menu ID */
  161. #define    editMenu    257        /*    Edit Menu ID */
  162. #define termMenu    258        /*    Emulation Menu ID */
  163. #define    connMenu    259        /*    Connection Menu ID */
  164. #define netMenu        260        /*    Network Menu Resource ID */
  165. #define fontMenu    128        /*  Font Menu Resource ID */
  166. #define sizeMenu    129        /*    Size Menu Resource ID */
  167.  
  168. #define    Fil            1        /*    File Menu's Position */
  169. #define Edit        2        /*  Edit Menu's Position */
  170. #define    Emul        3        /*    Emulation Menu's position */
  171. #define Net            4        /*    Network Menu's position */
  172. #define Conn        5        /*    Connection Menu's position */
  173. #define Font        6        /*    Font Menu's position */
  174. #define Size        7        /*  Size Menu's position */
  175.  
  176. /* ----------------- The File Menu ---------------------- */
  177. #define FLopen        1        /* File Menu: Open Connection */
  178. #define    FLclose        2        /* File Menu: Close Connection */
  179. #define    FLload        4        /* File Menu: Load Set */
  180. #define    FLsave        5        /* File Menu: Save Set */
  181. #define FLftp        7        /* File Menu: ftp on */
  182. #define FLbin        8        /* File Menu: MacBinary on */
  183. #define FLlog        9        /* File Menu: ftp log on */
  184. #define FLdir         10        /* File Menu: Set Transfer Directory */
  185. #define FLprint        12        /* File Menu: Print Selection */
  186. #define FLpset        13        /* File Menu: Page Setup */
  187. #define FLquit        15        /* File Menu: Quit */
  188. #define FLsession    16        /* ftp session */
  189.  
  190. /* ----------------- The Edit Menu ---------------------- */
  191. #define    EDundo        1
  192. #define EDcut        3
  193. #define EDcopy        4        /* Edit Menu: Copy */
  194. #define EDpaste        5        /* Edit Menu: Paste */
  195. #define EDclear        6        /* Edit Menu: Clear */
  196. #define EDcopyt        7        /* Edit Menu: Copy Table */
  197. #define EDmacros    9        /* Edit Menu: Macros */
  198. #define EDprefs        10        /* Edit Menu: Preferences */
  199.  
  200. /* ----------------- The Session Menu ---------------------- */
  201. #define EMbs        1        /* Emulation Menu: backspace */
  202. #define EMdel        2        /* Emulation Menu: delete */
  203. #define EMecho        4        /* Emulation Menu: echo */
  204. #define EMwrap      5       /* Emulation Menu: Wrap mode on/off */
  205. #define EMscroll    6        /* Emulation Menu: Clear Screen Saves Lines */
  206. #define EMreset     7        /* Emulation Menu: Reset Terminal */
  207. #define EMjump        8        /* Emulation Menu: Jump Scroll */
  208. #define EMpage        9        /* Emulation Menu: TEK Page command */
  209. #define EMclear        10        /* BYU 2.4.8 - Emulation Menu: TEK Page clears screen */
  210. #define EMlines        12        /* BYU 2.4.8 - Emulation Menu: Set Usable Lines */
  211. #define EMsetup     13      /* BYU 2.4.8 - Emulation Menu: Setup keys */
  212. #define EMfont        14        /* BYU 2.4.8 - Emulation Menu: Font */
  213. #define EMsize        15        /* BYU 2.4.8 - Emulation Menu: Size */
  214. #define EMcolor        16        /* BYU 2.4.8 - Emulation Menu: Color */
  215. #define EMslip        18        /* BYU 2.4.15 - Emulation Menu: Switch to SLIP */
  216. #define EMserial    19        /* BYU 2.4.15 - Emulation Menu: Switch to Serial */
  217. #define EMcapture    21        /* BYU 2.4.18 - Emulation Menu: Capture to file */
  218.  
  219. /* ----------------- The Network Menu ---------------------- */
  220. /* #define NEcommand    19    Emulation Menu: Command Keys */
  221. #define    NEftp        1        /* Emulation Menu: Send ftp command */
  222. #define    NEip        2        /* Emulation Menu: Send IP # */
  223. #define NEayt        4        /* Emulation Menu: Send "Are You There" */
  224. #define NEao        5        /* Emulation Menu: Send "Abort Output" */
  225. #define NEinter        6        /* Emulation Menu: Send "Interrupt Process" */
  226. #define NEec        7        /* Emulation Menu: Send "Erase Character" */
  227. #define NEel        8        /* Emulation Menu: Send "Erase Line" */
  228. #define NEscroll    10        /* Network Menu: Scroll Lock */
  229. #define NEnet        12        /* Network Menu: Show Net #'s */
  230. #define NEconfig    13        /* Network Menu: Configure Network */
  231. #define NEserial    14        /* Network Menu: Serial Port Settings */    /* BYU serial */
  232. #define NEalias        15        /* NCSA: alias menu item    */
  233.  
  234.  
  235. #define YESFTP 1
  236. #define NOFTP 0
  237.  
  238. #define    NMENUS    8            /*    We have NMENUS menus right now */
  239.  
  240. #define COnext        1        /* Connection Menu: Next Session... */
  241. #define CR            0x0d    /* the carriage return character */
  242. #define    BS            0x08    /* the backspace character */
  243. #define TAB            9
  244.  
  245. /*
  246.  *    Internal Variable declarations 
  247.  */
  248.  
  249. static ResType    creator         = 'NCSA';    /* BYU LSC */
  250. static ResType    filetype         = 'CONF';    /* BYU LSC */
  251.  
  252. short 
  253.     modalItems,                /* BYU 2.4.15 */
  254.     modalItem[3] = {0,0},    /* BYU 2.4.15 - Item no. for modal cmd key feature */
  255.     modalKey[3],            /* BYU 2.4.15 - Key code for modal cmd key feature */
  256.     *FontNumber = 0L;        /* Array of Font Numbers */
  257. int
  258.     *FontSize = 0L;            /* Array of Font Sizes */
  259. int
  260.     nFontNumber=0,            /* # of font Numbers */
  261.     nFontSize = 0,            /* # of font sizes */
  262.     ScrlLock=0,                /* Are we in network suspend mode */
  263.     ftpavail=0,                /* Is ftp available (default no ) */    /* BYU 2.4.12 */
  264.     ftplogon=0,                /* Is ftp log visible (default no) */
  265.     whichMenus=0;            /* 0 is old 1 is new */
  266.  
  267. extern SysEnvRec theWorld;    /* BYU 2.4.18 - System Environment record */
  268.  
  269. extern short 
  270.     serial_scrn,        /* BYU 2.4.15 */
  271.     slip_connection;    /* BYU 2.4.15 */
  272.  
  273. extern Cursor
  274.     *graphcurs,        /* Cursor when in graphic window */
  275.     *normcurs;        /* Cursor for non-transfer normal mode */
  276.  
  277. extern Handle hKCHR;        /* BYU 2.4.12 - Handle for keyboard mapping stuff (event.c) */
  278.  
  279. THPrint
  280.     prRecHdl=0L;            /* our print record handle */
  281.  
  282. MenuHandle
  283.     myMenus[NMENUS];        /* Menu Handles .... */
  284.  
  285. char
  286.     stupidarray[150];        /* A stupid array for finding the stringwidth */
  287.  
  288. short setdir;
  289.  
  290. #define VMARGINS 4
  291.  
  292. /*
  293.  * External variable declarations (those which we borrow )
  294.  *
  295.  */
  296. extern WindRec
  297.     *screens,            /* The screen array from Maclook */
  298.     ftplog,                    /* The FTP log screen from Maclook */
  299.     console;
  300.  
  301. extern short cmask;
  302.  
  303. extern int
  304.     defaultv,            /* BYU 2.4.18 */
  305.     done,                /* BYU */
  306.     KIP,
  307.     MacBinary,
  308.     EtherNet,
  309.     dynamic,
  310.     userlevel,
  311.     ctrl,                    /* Control key ... */
  312.     scrn,                    /* The current screen from Maclook */
  313.     numwindows;                /* The number of windows now from Maclook */
  314. extern int
  315.     HasColor;
  316. extern long
  317.     defmask,        /* BYU LSC - The network mask as per defaults contingent on the IP */
  318.     mynetmask;        /* BYU LSC - The network mask as per user config */
  319.  
  320. extern unsigned char
  321.     KIPserver[4],            /* BYU 2.4.15 - KIP gateway address */
  322.     SLIP_ip_number[];        /* BYU 2.4.15 */
  323.  
  324. DialogPeek    myDPeek;
  325.  
  326. char tempspot[256];                /* temporary storage */
  327.  
  328.  
  329. extern unsigned char
  330.     myipnum[4],                /* My current IP Number from Maclook */
  331.     nnmyaddr[4];            /* My cuurent hardware address  from Maclook */
  332.  
  333. extern Str255
  334.     *defaultd,        /* Default host name */
  335.     *dvs;            /* Default Volume/directory specification */
  336. /*
  337.  * Internal predeclared functions
  338.  */
  339. pascal void
  340.     VersionNumber(),
  341.     OutlineItem();
  342. pascal short
  343.     modalProc();
  344. void
  345.     printsleep();            /* The netsleep/ print cancel procedure */
  346.  
  347. PicHandle
  348.     RGtoPICT();                /* Convert Drawings to pictures */
  349. int
  350.     portsOpen();            /* 0 if none, 1 if active, -1 if not active */
  351.  
  352.  
  353. /*
  354.  * External predeclared functions
  355.  */
  356. extern char
  357.     **RSGetTextSel();        /* Convert text to char handle  from RSmac */
  358.  
  359. #if 0                            /* BYU LSC */
  360. char *strncpy();
  361. #endif                            /* BYU LSC */
  362.  
  363. extern void close_mb_files();    /* BYU */
  364.  
  365. #ifndef MPW
  366. Str255 *ptoc(),*ctop();
  367. #endif MPW
  368.  
  369.  
  370. CloseCaptureFile(int w) {
  371.     VSclosecapture(w);                                /* BYU 2.4.18 */
  372.     CheckItem(myMenus[Emul], EMcapture,FALSE);        /* BYU 2.4.18 */
  373. }
  374.  
  375.  
  376. /* Allow the operator to "Switch to Serial" only when         /* BYU 2.4.15 */
  377. /* all of the SLIP connections have been closed.            /* BYU 2.4.15 */
  378.                                                             /* BYU 2.4.15 */
  379. /* Allow the operator to "Switch to SLIP" only when         /* BYU 2.4.15 */
  380. /* the front most session is a serial session.                /* BYU 2.4.15 */
  381.                                                             /* BYU 2.4.15 */
  382. SLIP_menus() {                                                /* BYU 2.4.15 */
  383.     short i;                                                /* BYU 2.4.15 */
  384.                                                             /* BYU 2.4.15 */
  385.     if (serial_scrn>=0) {                                    /* BYU 2.4.15 */
  386.                                                             /* BYU 2.4.15 */
  387.         if (!slip_connection) {                                /* BYU 2.4.15 */
  388.                                                             /* BYU 2.4.15 */
  389.             if (screens[scrn].connectionType == 0)            /* BYU 2.4.15 */
  390.                 DisableItem (myMenus[Emul], EMslip);        /* BYU 2.4.15 */
  391.             else                                            /* BYU 2.4.15 */
  392.                 EnableItem (myMenus[Emul], EMslip);            /* BYU 2.4.15 */
  393.                                                             /* BYU 2.4.15 */
  394.             DisableItem (myMenus[Emul], EMserial);            /* BYU 2.4.15 */
  395.             CheckItem(myMenus[Emul], EMslip, FALSE);        /* BYU 2.4.15 */
  396.             CheckItem(myMenus[Emul], EMserial, TRUE);        /* BYU 2.4.15 */
  397.                                                             /* BYU 2.4.15 */
  398.         } else {                                            /* BYU 2.4.15 */
  399.                                                             /* BYU 2.4.15 */
  400.             DisableItem ( myMenus[Emul], EMslip);            /* BYU 2.4.15 */
  401.             CheckItem(myMenus[Emul], EMslip, TRUE);            /* BYU 2.4.15 */
  402.             CheckItem(myMenus[Emul], EMserial, FALSE);        /* BYU 2.4.15 */
  403.                                                             /* BYU 2.4.15 */
  404.             i=0;                                                        /* BYU 2.4.15 */
  405.             while((i<numwindows) && (screens[i].connectionType == 0))    /* BYU 2.4.15 */
  406.                 i++;                                                    /* BYU 2.4.15 */
  407.             if (i>= numwindows) {                            /* BYU 2.4.15 */
  408.                 EnableItem (myMenus[Emul], EMserial);        /* BYU 2.4.15 */
  409.             } else {                                        /* BYU 2.4.15 */
  410.                 DisableItem (myMenus[Emul], EMserial);        /* BYU 2.4.15 */
  411.             }                                                /* BYU 2.4.15 */
  412.         }                                                    /* BYU 2.4.15 */
  413.                                                             /* BYU 2.4.15 */
  414.     } else {                                                /* BYU 2.4.15 */
  415.         DisableItem ( myMenus[Emul],EMslip);                /* BYU 2.4.15 */
  416.         DisableItem ( myMenus[Emul],EMserial);                /* BYU 2.4.15 */
  417.         if (slip_connection) {                                /* BYU 2.4.16 */
  418.             CheckItem(myMenus[Emul], EMslip, TRUE);            /* BYU 2.4.16 */
  419.             CheckItem(myMenus[Emul], EMserial, FALSE);        /* BYU 2.4.16 */
  420.         } else {                                            /* BYU 2.4.16 */
  421.             CheckItem(myMenus[Emul], EMslip, FALSE);        /* BYU 2.4.16 */
  422.             CheckItem(myMenus[Emul], EMserial, TRUE);        /* BYU 2.4.16 */
  423.         }                                                    /* BYU 2.4.16 */
  424.     }                                                        /* BYU 2.4.15 */
  425. }                                                            /* BYU 2.4.15 */
  426.  
  427. void AdjustMenus
  428.   (
  429.     void
  430.   )
  431. {
  432.     int i;
  433.  
  434.     if ((i=portsOpen()) <1) {
  435.         DisableItem( myMenus[Fil],FLclose);
  436.         DisableItem( myMenus[Fil],FLsave);
  437.         DisableItem( myMenus[Fil],FLprint);
  438. #ifdef CANTQUIT
  439.         EnableItem ( myMenus[Fil],FLquit);
  440. #endif
  441.         DisableItem( myMenus[Edit],EDcut);
  442.         DisableItem( myMenus[Edit],EDundo);
  443.         DisableItem( myMenus[Edit],EDclear);
  444.         DisableItem( myMenus[Edit],EDcopy);
  445.         DisableItem( myMenus[Edit],EDcopyt);
  446.  
  447.  
  448.         DisableItem( myMenus[Emul],EMbs);
  449.         DisableItem( myMenus[Emul],EMdel);
  450.         DisableItem( myMenus[Emul],EMecho);
  451.         DisableItem( myMenus[Emul],EMwrap);
  452.         DisableItem( myMenus[Emul],EMscroll);
  453.         DisableItem( myMenus[Emul],EMreset);
  454.         DisableItem ( myMenus[Emul],EMjump);
  455.         DisableItem ( myMenus[Emul],EMpage);
  456.         DisableItem ( myMenus[Emul],EMclear);    /* BYU 2.4.14 */
  457.         DisableItem ( myMenus[Emul],EMlines);
  458.         DisableItem ( myMenus[Emul],EMsetup);
  459.         DisableItem ( myMenus[Emul],EMfont);
  460.         DisableItem ( myMenus[Emul],EMsize);
  461.         DisableItem ( myMenus[Emul],EMcolor);
  462.         DisableItem ( myMenus[Emul],EMslip);    /* BYU 2.4.15 */
  463.         DisableItem ( myMenus[Emul],EMserial);    /* BYU 2.4.15 */
  464.         DisableItem ( myMenus[Emul],EMcapture);    /* BYU 2.4.18 */
  465.  
  466.         DisableItem( myMenus[Net ],NEftp);
  467.         DisableItem( myMenus[Net ],NEip);
  468.         DisableItem( myMenus[Net ],NEayt);
  469.         DisableItem( myMenus[Net ],NEao);
  470.         DisableItem( myMenus[Net ],NEinter);
  471.         DisableItem( myMenus[Net ],NEec);
  472.         DisableItem( myMenus[Net ],NEel);
  473.         DisableItem( myMenus[Net ],NEscroll);
  474.         if (userlevel==0 ) 
  475.             EnableItem( myMenus[Net], NEconfig);
  476.  
  477.         if (i<0) {
  478.             EnableItem ( myMenus[Fil ],FLclose);
  479.             }
  480.         if (ScrlLock) {
  481.             ScrlLock=0;
  482.             CheckItem(myMenus[Net ], NEscroll,FALSE);
  483.             }
  484.         }
  485.     else {
  486.         EnableItem ( myMenus[Fil],FLclose);
  487.         EnableItem ( myMenus[Fil],FLsave);
  488.  
  489. /*        EnableItem ( myMenus[Fil],FLprint); */
  490.  
  491. #ifdef CANTQUIT
  492.         DisableItem( myMenus[Fil],FLquit);
  493. #endif
  494.  
  495.         EnableItem ( myMenus[Emul],EMbs);
  496.         EnableItem ( myMenus[Emul],EMdel);
  497.         EnableItem ( myMenus[Emul],EMecho);
  498.         EnableItem ( myMenus[Emul],EMwrap);
  499.         EnableItem ( myMenus[Emul],EMscroll);
  500.         EnableItem ( myMenus[Emul],EMreset);
  501.         EnableItem ( myMenus[Emul],EMjump);
  502.         EnableItem ( myMenus[Emul],EMpage);
  503.         EnableItem ( myMenus[Emul],EMclear);    /* BYU 2.4.14 */
  504.         EnableItem ( myMenus[Emul],EMlines);
  505.         EnableItem ( myMenus[Emul],EMsetup);
  506.         EnableItem ( myMenus[Emul],EMfont);
  507.         EnableItem ( myMenus[Emul],EMsize);
  508.         EnableItem ( myMenus[Emul],EMcapture);    /* BYU 2.4.18 */
  509.     
  510.         if (HasColor) 
  511.             EnableItem ( myMenus[Emul],EMcolor);
  512.  
  513.         EnableItem ( myMenus[Net ],NEftp);
  514.         EnableItem ( myMenus[Net ],NEip);
  515.         EnableItem ( myMenus[Net ],NEayt);
  516.         EnableItem ( myMenus[Net ],NEao);
  517.         EnableItem ( myMenus[Net ],NEinter);
  518.         EnableItem ( myMenus[Net ],NEec);
  519.         EnableItem ( myMenus[Net ],NEel);
  520.         EnableItem ( myMenus[Net ],NEscroll);
  521.         if (EtherNet == -99)
  522.             EnableItem( myMenus[Net ],NEconfig);
  523.         else
  524.             DisableItem( myMenus[Net ],NEconfig);
  525.     }
  526.  
  527.     SLIP_menus();                                /* BYU 2.4.15 */
  528. }
  529.  
  530. /*
  531.  *    switchMenus( which) - Switch from our current menus to the key menus (1)
  532.  *                          or the normal menus (0).
  533.  */
  534.  
  535. void switchMenus
  536.   (
  537.     int which
  538.   )
  539. {
  540.     int i;
  541.  
  542.     DeleteMenu( fileMenu);                    /* Take them from the menu bar */
  543.     DeleteMenu( editMenu);
  544.     DeleteMenu( termMenu);
  545.     DeleteMenu(  netMenu);
  546.  
  547.     if (which) {
  548.         myMenus[Fil ] = GetMenu(NfileMenu);
  549.         myMenus[Edit] = GetMenu(NeditMenu);
  550.         myMenus[Emul] = GetMenu(NtermMenu);
  551.         myMenus[Net ] = GetMenu(NnetMenu );
  552.         DelMenuItem(myMenus[Conn],1);
  553.         InsMenuItem(myMenus[Conn],"\017Next Session/N\0",0);
  554.         ctrl = optionKey;                    /* Option key is the control key.... */
  555.         }
  556.     else {
  557.         myMenus[Fil ] = GetMenu(fileMenu);
  558.         myMenus[Edit] = GetMenu(editMenu);
  559.         myMenus[Emul] = GetMenu(termMenu);
  560.         myMenus[Net ] = GetMenu( netMenu);
  561.         DelMenuItem(myMenus[Conn],1);
  562.         InsMenuItem(myMenus[Conn],"\015Next Session\0",0);
  563.  
  564.         ctrl = cmdKey;                        /* Command key is the control key... */
  565.         }
  566.  
  567.     for(i=1; i<Conn; i++)
  568.         InsertMenu( myMenus[i], connMenu);    /* Put them in the menu bar */
  569.  
  570.     AdjustMenus();            /* Hilite the right stuff */
  571.  
  572.     if (MacBinary)
  573.         CheckItem(myMenus[Fil],FLbin,TRUE);        /* Check MacBinary ... */
  574.     else
  575.         CheckItem(myMenus[Fil],FLbin,FALSE);
  576.  
  577.     if (ftpavail) 
  578.         CheckItem(myMenus[Fil],FLftp,TRUE);        /* Check ftpavail ... */
  579.     else
  580.         CheckItem(myMenus[Fil],FLftp,FALSE);
  581.  
  582.     if (ftplogon)
  583.         CheckItem(myMenus[Fil],FLlog,TRUE);        /* and the log .... */
  584.     else
  585.         CheckItem(myMenus[Fil],FLlog,FALSE);
  586.  
  587.     if (ScrlLock)                                 /* and the Suspend network ... */
  588.         CheckItem(myMenus[Net], NEscroll,TRUE);
  589.     else 
  590.         CheckItem(myMenus[Net], NEscroll,FALSE);
  591.  
  592.     if (numwindows>0)                            /* and set the BSDEL flag */
  593.         CheckItem(myMenus[Emul], EMbs+screens[scrn].bsdel,FALSE);
  594.  
  595. /*    SLIP_menus();                                /* BYU 2.4.15 */
  596.  
  597.     DrawMenuBar();                                /* Draw what we have done */
  598.  
  599.     SLIP_menus();                                /* BYU 2.4.18 */
  600.  
  601.     if (userlevel!=0) 
  602.         DisableItem( myMenus[Net], NEconfig);
  603.     if (!HasColor)
  604.         DisableItem( myMenus[Emul], EMcolor);
  605.  
  606. }
  607.  
  608. /*
  609.  *    setupmenu - Set up (load) all menus and prepare menu bar.
  610.  *                set default check marks.
  611.  */
  612.  
  613. void setupmenu
  614.   (
  615.     int def
  616.   )
  617. {
  618.     int i;
  619.     Str255 temp;            /* BYU LSC */
  620.  
  621.     ftpavail = Sfmode();                        /* Get the FTP Mode from session layer */
  622.     for (i=0; i<150; i++) stupidarray[i]='W';    /* Set up the width array */
  623.     myMenus[0] = GetMenu(appleMenu);                /* Get all of our friendly menus */
  624.     myMenus[Conn] = GetMenu(connMenu);
  625.     myMenus[Font] = GetMenu(fontMenu);
  626.     myMenus[Size] = GetMenu(sizeMenu);
  627.  
  628.     AddResMenu(myMenus[0], 'DRVR');                    /* Add in the DA's */
  629.  
  630.     InsertMenu(myMenus[0], 0);                        /* Insert the Menus into the bar */
  631.     InsertMenu(myMenus[Conn], 0);
  632.     InsertMenu(myMenus[Font], -1);
  633.     InsertMenu(myMenus[Size], -1);
  634.     
  635.  
  636.     AddResMenu(myMenus[Font], 'FONT');                /* Put the fonts in the font menu */
  637.  
  638.     nFontNumber = i = CountMItems( myMenus[Font]);    /* Initialize the FontNumber[] array*/
  639.     FontNumber = (short *) NewPtr( sizeof(short) *(i+1));    /* BYU LSC */
  640.     for (;i>0;i--) {
  641.         GetItem( myMenus[Font], i, temp);                /* BYU LSC */
  642.         GetFNum( temp, &FontNumber[i]);                    /* BYU LSC - With the font numbers */
  643.         }
  644.  
  645.     nFontSize = i = CountMItems( myMenus[Size]);     /* Initialize the FontSize[] array */
  646.     FontSize = (int *) NewPtr( sizeof(int) *(i+1));        /* BYU LSC */
  647.     for (;i>0;i--) {
  648.         GetItem( myMenus[Size], i, temp);                /* BYU LSC */
  649. #ifndef MPW
  650.         p2cstr(temp);                                    /* BYU LSC */
  651. #endif MPW
  652.         sscanf((char *) temp, "%d", &FontSize[i]);        /* BYU LSC - Read from the resource itself */
  653.         }
  654.  
  655.     FontNumber[0]=0;
  656.     FontSize[0]=0;
  657.  
  658.     switchMenus(def);
  659. }
  660.  
  661.  
  662. /*
  663.  *    updateMenuChecks() - update the check marks for file transfer
  664.  *                         (MacBinary and ftpavail)
  665.  */
  666.  
  667. void updateMenuChecks
  668.   (
  669.     void
  670.   )
  671. {
  672.     if (MacBinary)
  673.         CheckItem(myMenus[Fil],FLbin,TRUE);        /* Check MacBinary ... */
  674.     else
  675.         CheckItem(myMenus[Fil],FLbin,FALSE);
  676.  
  677.     ftpavail = Sfmode();
  678.     if (ftpavail) 
  679.         CheckItem(myMenus[Fil],FLftp,TRUE);        /* Check ftpavail ... */
  680.     else
  681.         CheckItem(myMenus[Fil],FLftp,FALSE);
  682. }
  683.  
  684. /*
  685.  *    DisplayMacBinary()    - Sets the macbinary check mark according to the 
  686.  *                          MacBinary flag 
  687.  */
  688.  
  689. void DisplayMacBinary
  690.   (
  691.     void
  692.   )
  693. {
  694.     if (MacBinary)
  695.         CheckItem(myMenus[Fil],FLbin,TRUE);        /* Check MacBinary ... */
  696.     else
  697.         CheckItem(myMenus[Fil],FLbin,FALSE);
  698. }
  699.  
  700. /*
  701.  *     CheckFonts()        - Place checkmarks and outlines on the appropriate
  702.  *                          menu items for the fonts 
  703.  */
  704.  
  705. CheckFonts()
  706. {
  707.     int i, fsiz, fnum;
  708.  
  709.     RSgetfont( screens[scrn].vs, &fnum, &fsiz);
  710.  
  711.     for(i=1; i<=nFontNumber;i++)
  712.         if (fnum == FontNumber[i])                        /* Check Our Current Font */
  713.             CheckItem( myMenus[Font], i, TRUE);
  714.         else
  715.             CheckItem( myMenus[Font], i, FALSE);
  716.  
  717.     for(i=1; i<=nFontSize;i++) {
  718.         if (fsiz == FontSize[i])
  719.             CheckItem( myMenus[Size], i, TRUE);            /* Check Our Current Size */
  720.         else
  721.             CheckItem( myMenus[Size], i, FALSE);
  722.  
  723.         if (RealFont( fnum, FontSize[i]))                /* Outline All Available REAL Sizes */
  724.             SetItemStyle( myMenus[Size], i, 8);
  725.         else
  726.             SetItemStyle( myMenus[Size], i, 0);
  727.         }
  728. }
  729.  
  730. /*
  731.  *    applAbout - display the about dialog for the application.
  732.  *        Displays until clicked on.
  733.  */
  734. void applAbout
  735.   (
  736.     void
  737.   )
  738. {
  739.     DialogPtr About;
  740.     short itemhit;
  741.  
  742.     About=GetNewDialog( 501, (Ptr) 0L,(WindowPtr) -1L);
  743.     if (About) {
  744.         ModalDialog((ModalFilterProcPtr) modalProc, &itemhit);
  745.         DisposDialog(About);
  746.         }
  747.  
  748.     About=GetNewDialog( 256, (Ptr) 0L,(WindowPtr) -1L);
  749.     UItemAssign( About, 2, (int (*)()) VersionNumber);
  750.     ModalDialog((ModalFilterProcPtr) modalProc, &itemhit);
  751.     DisposDialog(About);
  752.     
  753. }
  754.  
  755. /*
  756.  *    configport -    Used to reconfigure a session
  757.  */
  758.  
  759. int configport
  760.   (
  761.     ConfigRec *config
  762.   )
  763. {
  764.     /*  struct machinfo *mp;  */
  765.     DialogPtr dtemp;
  766.     int SBon=1, Del=1, width=80, tek=1,cr=1,echo=1,tektype,line,eightbit;    /* BYU 2.4.9 */
  767.     short dItem;
  768.     Str255 temps,*tempp;
  769.     Rect dBox;
  770.     Handle host,name,scrlon,scrlnum,kbbs,kbdel,w132,w80,tekclear,tekcreate,
  771.             crLF, crNUL,echoBuff,echoSend,tekold,teknew,lineyes,lineno,        /* BYU 2.4.9 */
  772.             eightyes,eightno;                                                /* BYU 2.4.9 */
  773.  
  774.     SetCursor(normcurs);
  775.     
  776.     SBon=config->scrollback>0;
  777.     Del=config->bsdel;
  778.     width= config->width;
  779.     tek= config->tekclear;
  780.     cr = config->crmap == 10;
  781.     echo =  !config->halfdup;
  782.     tektype = config->tektype;
  783.     line = config->lineAllow;
  784.     eightbit = config->eightbit;    /* BYU 2.4.9 */
  785.     
  786.     tempp = (Str255 *) temps;
  787.     dtemp=GetNewDialog( SConfigDLOG,(Ptr) 0L,(WindowPtr) -1L);    /* Bring on the box */
  788.     UItemAssign( dtemp, 25, (int (*)()) OutlineItem);
  789.  
  790. #ifndef MPW
  791.     c2pstr(config->machine);        /* BYU LSC */
  792. #endif MPW
  793.  
  794.     GetDItem( dtemp, SChost, &dItem, &host, &dBox);    /* Install the default host */
  795.     SetIText( host , config->machine);                /* BYU LSC */
  796.  
  797.     GetDItem( dtemp, SCname, &dItem, &name, &dBox);    /* Install the default name */
  798.     c2pstr(config->name);                            /* BYU LSC */
  799.     SetIText( name, config->name);                    /* BYU LSC - Here is default */
  800.     p2cstr(config->name);                            /* BYU LSC */
  801.     SelIText( dtemp, SCname, 0, 32767);                /* And select it... */
  802.  
  803.     GetDItem( dtemp, SCscrolnum, &dItem, &scrlnum, &dBox);    /* Default Scrollback */
  804.     sprintf((char *) tempp, "%d", SBon?config->scrollback:120);
  805. #ifndef MPW
  806.     c2pstr((char *) tempp);                            /* BYU LSC */
  807. #endif MPW
  808.     SetIText( scrlnum, (char *) tempp);                /* BYU LSC */
  809.  
  810.     GetDItem( dtemp, SCscrolon, &dItem, &scrlon, &dBox);        /* Get all of the handles now */
  811.     GetDItem( dtemp, SCkbbs, &dItem, &kbbs, &dBox);
  812.     GetDItem( dtemp, SCkbdel, &dItem, &kbdel, &dBox);
  813.     GetDItem( dtemp, SCwidth132, &dItem, &w132, &dBox);
  814.     GetDItem( dtemp, SCwidth80, &dItem, &w80, &dBox);
  815.     GetDItem( dtemp, SCtekclear, &dItem, &tekclear, &dBox);
  816.     GetDItem( dtemp, SCtekcreate, &dItem, &tekcreate, &dBox);
  817.     GetDItem( dtemp, SCcrLF, &dItem, &crLF, &dBox);
  818.     GetDItem( dtemp, SCcrNUL, &dItem, &crNUL, &dBox);
  819.     GetDItem( dtemp, SCechoBuff, &dItem, &echoBuff, &dBox);
  820.     GetDItem( dtemp, SCechoSend, &dItem, &echoSend, &dBox);
  821.     GetDItem( dtemp, SCtekold, &dItem, &tekold, &dBox);
  822.     GetDItem( dtemp, SCteknew, &dItem, &teknew, &dBox);
  823.     GetDItem( dtemp, SClineY, &dItem, &lineyes, &dBox);
  824.     GetDItem( dtemp, SClineN, &dItem, &lineno, &dBox);
  825.     GetDItem( dtemp, SCeightY, &dItem, &eightyes, &dBox);    /* BYU 2.4.9 */
  826.     GetDItem( dtemp, SCeightN, &dItem, &eightno, &dBox);    /* BYU 2.4.9 */
  827.  
  828. /*    HiliteControl(w132, 255); */
  829.  
  830.     SetCtlValue((ControlHandle) scrlon, SBon);
  831.     SetCtlValue((ControlHandle) kbdel, Del);
  832.     SetCtlValue((ControlHandle) kbbs, !Del);
  833.     SetCtlValue((ControlHandle) w132, (width==132));
  834.     SetCtlValue((ControlHandle) w80, !(width==132));
  835.     SetCtlValue((ControlHandle) tekcreate, !tek);
  836.     SetCtlValue((ControlHandle) tekclear ,  tek);
  837.     SetCtlValue((ControlHandle) crLF ,  cr);
  838.     SetCtlValue((ControlHandle) crNUL, !cr);
  839.     SetCtlValue((ControlHandle) echoBuff,  echo);
  840.     SetCtlValue((ControlHandle) echoSend,  !echo);
  841.     SetCtlValue((ControlHandle) tekold,  !tektype);
  842.     SetCtlValue((ControlHandle) teknew,  tektype);
  843.     SetCtlValue((ControlHandle) lineyes,  line);
  844.     SetCtlValue((ControlHandle) lineno,  !line);
  845.     SetCtlValue((ControlHandle) eightyes,  eightbit);    /* BYU 2.4.9 */
  846.     SetCtlValue((ControlHandle) eightno,  !eightbit);    /* BYU 2.4.9 */
  847.  
  848.  
  849.     dItem=0;                                /* initially no hits */
  850.     while((dItem>2) || (dItem==0)) {        /* While we are in the loop */
  851.         ModalDialog((ModalFilterProcPtr)modalProc,&dItem); /* and do our duty to the box */
  852.         switch( dItem) {
  853.             case SCscrolon:
  854.                 SBon=!SBon;
  855.                 SetCtlValue((ControlHandle) scrlon, SBon);
  856.                 break;
  857.             case SCkbbs:
  858.                 Del=0;
  859.                 SetCtlValue((ControlHandle) kbbs, !Del);
  860.                 SetCtlValue((ControlHandle) kbdel, Del);
  861.                 break;
  862.             case SCkbdel:
  863.                 Del=1;
  864.                 SetCtlValue((ControlHandle) kbdel, Del);
  865.                 SetCtlValue((ControlHandle) kbbs, !Del);
  866.                 break;
  867.             case SCwidth132:
  868.                 width=132;
  869.                 SetCtlValue((ControlHandle) w132, (width==132));
  870.                 SetCtlValue((ControlHandle) w80,  (width!=132));
  871.                 break;
  872.             case SCwidth80:
  873.                 width=80;
  874.                 SetCtlValue((ControlHandle) w132, (width==132));
  875.                 SetCtlValue((ControlHandle) w80,  (width!=132));
  876.                 break;
  877.             case SCtekclear:
  878.                 tek=1;
  879.                 SetCtlValue((ControlHandle) tekcreate, !tek);
  880.                 SetCtlValue((ControlHandle) tekclear ,  tek);
  881.                 break;
  882.             case SCtekcreate:
  883.                 tek=0;
  884.                 SetCtlValue((ControlHandle) tekcreate, !tek);
  885.                 SetCtlValue((ControlHandle) tekclear ,  tek);
  886.                 break;
  887.             case SCcrLF:
  888.                 cr=1;
  889.                 SetCtlValue((ControlHandle) crLF ,  cr);
  890.                 SetCtlValue((ControlHandle) crNUL, !cr);
  891.                 break;
  892.             case SCcrNUL:
  893.                 cr=0;
  894.                 SetCtlValue((ControlHandle) crLF ,  cr);
  895.                 SetCtlValue((ControlHandle) crNUL, !cr);
  896.                 break;
  897.             case SCechoBuff:
  898.                 echo=1;
  899.                 SetCtlValue((ControlHandle) echoBuff,  echo);
  900.                 SetCtlValue((ControlHandle) echoSend,  !echo);
  901.                 break;
  902.             case SCechoSend:
  903.                 echo=0;
  904.                 SetCtlValue((ControlHandle) echoBuff,  echo);
  905.                 SetCtlValue((ControlHandle) echoSend,  !echo);
  906.                 break;
  907.             case SCtekold:
  908.                 tektype=0;
  909.                 SetCtlValue((ControlHandle) tekold,  !tektype);
  910.                 SetCtlValue((ControlHandle) teknew,  tektype);
  911.                 break;
  912.             case SCteknew:
  913.                 tektype=1;
  914.                 SetCtlValue((ControlHandle) tekold,  !tektype);
  915.                 SetCtlValue((ControlHandle) teknew,  tektype);
  916.                 break;
  917.             case SClineY:
  918.                 line=1;
  919.                 SetCtlValue((ControlHandle) lineyes,  line);
  920.                 SetCtlValue((ControlHandle) lineno,  !line);
  921.                 break;
  922.             case SClineN:
  923.                 line=0;
  924.                 SetCtlValue((ControlHandle) lineyes,  line);
  925.                 SetCtlValue((ControlHandle) lineno,  !line);
  926.                 break;
  927.             case SCeightY:                                            /* BYU 2.4.9 */
  928.                 eightbit=1;                                            /* BYU 2.4.9 */
  929.                 SetCtlValue((ControlHandle) eightyes,  eightbit);    /* BYU 2.4.9 */
  930.                 SetCtlValue((ControlHandle) eightno,  !eightbit);    /* BYU 2.4.9 */
  931.                 break;                                                /* BYU 2.4.9 */
  932.             case SCeightN:                                            /* BYU 2.4.9 */
  933.                 eightbit=0;                                            /* BYU 2.4.9 */
  934.                 SetCtlValue((ControlHandle) eightyes,  eightbit);    /* BYU 2.4.9 */
  935.                 SetCtlValue((ControlHandle) eightno,  !eightbit);    /* BYU 2.4.9 */
  936.                 break;                                                /* BYU 2.4.9 */
  937.             }
  938.         }
  939.  
  940.     if (dItem==DLOGCancel) {
  941.             DisposDialog( dtemp);
  942.             updateCursor(1);
  943.             return(0);
  944.             }
  945.  
  946.     GetIText( host, config->machine);        /* BYU LSC - where do we go from here? */
  947.     GetIText( name, config->name);            /* BYU LSC - And what is its name ...  */
  948.     p2cstr(config->name);                    /* BYU LSC */
  949.     if ( *config->name == 0 ) {
  950.         GetIText( host, config->name);        /* BYU LSC - Copy the host name in ... */
  951.         p2cstr(config->name);                /* BYU LSC */
  952.         }
  953.     GetIText( scrlnum, tempp);                /* BYU LSC - here is our ascii number */
  954.  
  955. #ifndef MPW
  956.     p2cstr((unsigned char *) tempp);        /* BYU LSC */
  957. #endif
  958.  
  959.     DisposDialog( dtemp);
  960.     updateCursor(1);
  961.  
  962. #ifndef MPW 
  963.     p2cstr((unsigned char *) config->machine);    /* BYU LSC */
  964. #endif
  965.  
  966.     config->scrollback=120;            /* Make certain that number will be valid */
  967.     if ( SBon) {
  968.             if (sscanf((char *) tempp, "%d", &config->scrollback) !=1) {
  969.                 config->scrollback=0;
  970.                 SBon = 0;
  971.                 }
  972.             }
  973.     else
  974.         config->scrollback=0;
  975.     config->lineAllow=line;
  976.     config->eightbit=eightbit;        /* BYU 2.4.9 */
  977.     config->bsdel=Del;
  978.     config->tektype=tektype;
  979.     config->width=width;
  980.     config->tekclear=tek;
  981.     config->halfdup= !echo;
  982.     if (cr)
  983.         config->crmap= 0x0a;
  984.     else 
  985.         config->crmap= 0x00;
  986.  
  987.     return(1);
  988. } /* configport */
  989.  
  990.  
  991.  
  992. pascal Boolean  theProc(theDialog,theEvent,theItem)
  993.     DialogPtr theDialog;
  994.     EventRecord *theEvent;
  995.     short *theItem;
  996. {
  997.     int    ascii;
  998.     OSErr err;
  999.     
  1000.     
  1001.     if (theEvent->what==keyDown || theEvent->what==autoKey)
  1002.         {
  1003.         ascii = theEvent->message & charCodeMask;
  1004.         if (ascii==CR || ascii==3) 
  1005.             {
  1006.             *theItem = 1;
  1007.             return -1;        /* BYU LSC - pascal doesn't like "1" as true */
  1008.             }
  1009.  
  1010.         if (theEvent->modifiers & cmdKey && theEvent->modifiers&shiftKey)
  1011.             if (ascii=='.')
  1012.                 {
  1013.                 *theItem =2;
  1014.                 return -1;    /* BYU LSC - pascal doesn't like "1" as true */
  1015.                 }
  1016.  
  1017.         if (theEvent->modifiers&cmdKey)
  1018.             {
  1019.             switch (ascii)
  1020.                 {
  1021.             
  1022.                 case 'v':    err=TEFromScrap();
  1023.                         DlgPaste(theDialog);
  1024.                         /*TEPaste(myDPeek.textH);*/
  1025.                         *theItem=5;
  1026.                         return -1;    /* BYU LSC - pascal doesn't like "1" as true */
  1027.                         break;
  1028.                 case 'c':
  1029.                         DlgCopy(theDialog);
  1030.                         ZeroScrap();
  1031.                         err=TEToScrap();
  1032.                         *theItem=5;
  1033.                         return -1;    /* BYU LSC - pascal doesn't like "1" as true */
  1034.                         break;
  1035.                 case 'x': 
  1036.                         DlgCut(theDialog);
  1037.                         ZeroScrap();
  1038.                         err=TEToScrap();
  1039.                         *theItem=5;
  1040.                         return -1;    /* BYU LSC - pascal doesn't like "1" as true */
  1041.                         break;            
  1042.             
  1043.                 }
  1044.             }
  1045.             
  1046.  
  1047.         if (theEvent->modifiers & ( optionKey | controlKey | cmdKey)) 
  1048.             {
  1049.             SysBeep(1);
  1050.             *theItem=5;
  1051.             return -1;        /* BYU LSC - pascal doesn't like "1" as true */
  1052.             }            
  1053.  
  1054.         if (isalnum(ascii) || (ascii=='.') || (ascii=='-') || (ascii==BS) || (ascii==' ') || (ascii==TAB));     
  1055.             return 0;
  1056.  
  1057.  
  1058.         SysBeep(1);
  1059.         *theItem=5;
  1060.         return -1;            /* BYU LSC - pascal doesn't like "1" as true */
  1061.         }
  1062.     return 0;
  1063. }
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070. /*
  1071.  *    setupport -    Used to start a session
  1072.  */
  1073.  
  1074. void setupport(theFtpFlag)
  1075.     short theFtpFlag;
  1076.     
  1077. {
  1078.     short cc;
  1079.     DialogPtr dtemp;
  1080.     ConfigRec config;
  1081.     int ftponly,oldscrn,serialonly;        /* BYU 2.4.15 */
  1082.     short dItem,myDitem;
  1083.     Str255 temps,*tempp;
  1084.     Rect dBox,myRect;
  1085.     Handle sessiontype,host,name,myHandle,okHandle;        /* BYU 2.4.15 */
  1086.     static numWind=1;
  1087.     char aTempStr[4];
  1088.     register short i;
  1089.     AliasRecord theAliasRec;            /* NCSA: data for this alias */
  1090.  
  1091.     /* struct machinfo *mp; */
  1092.  
  1093.     tempp = (Str255 *) temps;
  1094.  
  1095.     configdefault( &config);                    /* Start with the lowest of the low */
  1096.     if (theFtpFlag) config.ftpwind = 1;
  1097.     
  1098.     { char *p;
  1099.     if (NULL == (p = NewPtr(40000))) {            /* do we have enough memory? */
  1100.     
  1101. #ifndef MPW
  1102.         OtherError((char *) "\PNo memory for connnection",(char *) "\P ");    /* BYU LSC */
  1103. #else
  1104.         OtherError("Not enough memory left to open"," ");
  1105. #endif MPW
  1106.         return;
  1107.         }
  1108.     else
  1109.         DisposPtr(p);
  1110.     }
  1111.  
  1112.     config.name=NewPtr(256);                    /* Get some space for our name */
  1113.     config.machine=NewPtr(256);                    /* Get some space for our name */
  1114.     for (cc=0;cc<255;cc++)
  1115.             config.machine[cc] =0;
  1116.  
  1117.     dtemp=GetNewDialog( SessionDLOG,(Ptr) myDPeek,(WindowPtr) -1L);    /* Bring on the box */
  1118.      UItemAssign( dtemp, 8, (int (*)()) OutlineItem); 
  1119.  
  1120.     SetCursor(normcurs);
  1121.     
  1122.     GetDItem( dtemp, Shost, &dItem, &host, &dBox);    /* Install the default host */
  1123.     c2pstr((char *) defaultd);                        /* BYU LSC */
  1124.     SetIText( host, (char *) defaultd);                /* BYU LSC */
  1125.     p2cstr((char *) defaultd);                        /* BYU LSC */
  1126.     SelIText( dtemp, Shost, 0, 32767);                /* And select it... */
  1127.     GetDItem(dtemp,3,&myDitem,&myHandle,&myRect);
  1128.     GetDItem(dtemp,3,&myDitem,&okHandle,&dBox);
  1129.  
  1130.     GetDItem( dtemp, Sname, &dItem, &name, &dBox);    /* Install the default name */
  1131. /*    SetIText( name, defaultd);                        /* BYU LSC - No Default */
  1132.  
  1133.  
  1134.     modalItems = 2;        /* BYU 2.4.15 - indicate number of cmd keys active */
  1135.     modalItem[0] = 9;    /* BYU 2.4.15 - enable modal cmd key feature on item 9 */
  1136.     modalKey[0] = 3;    /* BYU 2.4.15 - cmd F key toggles FTP session button */
  1137.     modalItem[1] = 10;    /* BYU 2.4.15 - enable modal cmd key feature on item 10 */
  1138.     modalKey[1] = 1;    /* BYU 2.4.15 - cmd S key toggles Serial session button */
  1139.  
  1140.     ftponly = 0;    /* BYU */
  1141.  
  1142.     if (EtherNet == -100) {                                                /* BYU 2.4.15 */
  1143.         serialonly = 1;                                                    /* BYU 2.4.15 */
  1144.         GetDItem( dtemp, Sserialonly, &dItem, &sessiontype, &dBox);        /* BYU 2.4.15 */
  1145.         SetCtlValue( (ControlHandle) sessiontype, serialonly);            /* BYU 2.4.15 */
  1146.         HiliteControl((ControlHandle) sessiontype, 255);                /* BYU 2.4.15 */
  1147.         if (!slip_connection) {                                            /* BYU 2.4.15 */
  1148.             GetDItem( dtemp, Sftponly, &dItem, &sessiontype, &dBox);    /* BYU 2.4.15 */
  1149.             HiliteControl((ControlHandle) sessiontype, 255);            /* BYU 2.4.15 */
  1150.         }                                                                /* BYU 2.4.15 */
  1151.     } else                                                                /* BYU 2.4.15 */
  1152.         serialonly = 0;                                                    /* BYU 2.4.15 */
  1153.  
  1154.     dItem=0;                                /* initially no hits */
  1155.     GetIText( host, config.machine);        /* BYU LSC - where do we go from here? */
  1156.  
  1157.  
  1158.  
  1159.     while((dItem>3) || (dItem==0))            /* While we are in the loop */
  1160.         {
  1161.  
  1162.     if (*config.machine == 0) 
  1163.         {
  1164.         HiliteControl((ControlHandle)myHandle,255);                
  1165. /*        HiliteControl((ControlHandle)okHandle,255); */
  1166.         }        
  1167.     else 
  1168.         {
  1169.         HiliteControl((ControlHandle)myHandle,0);
  1170. /*        HiliteControl((ControlHandle)okHandle,0); */
  1171.         }
  1172.  
  1173.         ModalDialog((ModalFilterProcPtr) modalProc,&dItem);            /* BYU - and do our duty to the box */
  1174.         if (dItem == Sftponly && (EtherNet != -100 || slip_connection)) {    /* BYU 2.4.16 */
  1175.             ftponly = 1 - ftponly;                                        /* BYU - Toggle ftp session flag */
  1176.             GetDItem( dtemp, Sftponly, &dItem, &sessiontype, &dBox);    /* BYU serial */
  1177.             SetCtlValue( (ControlHandle) sessiontype, ftponly);                /* BYU serial */
  1178.             if ((slip_connection == 0) && (EtherNet != -100)) {                /* BYU 2.4.15 */
  1179.                 serialonly = 0;                                                /* BYU serial */
  1180.                 GetDItem( dtemp, Sserialonly, &dItem, &sessiontype, &dBox);    /* BYU serial */
  1181.                 SetCtlValue( (ControlHandle) sessiontype, serialonly);        /* BYU serial */
  1182.             }                                                                /* BYU 2.4.15 */
  1183.         } else if (dItem == Sserialonly && EtherNet != -100) {                /* BYU 2.4.16 */
  1184.             serialonly = 1 - serialonly;                                    /* BYU serial */
  1185.             GetDItem( dtemp, Sserialonly, &dItem, &sessiontype, &dBox);        /* BYU serial */
  1186.             SetCtlValue( (ControlHandle) sessiontype, serialonly);            /* BYU serial */
  1187.             if (slip_connection == 0) {                                        /* BYU 2.4.15 */
  1188.                 ftponly = 0;                                                /* BYU serial - Toggle ftp session flag */
  1189.                 GetDItem( dtemp, Sftponly, &dItem, &sessiontype, &dBox);    /* BYU serial */
  1190.                 SetCtlValue( (ControlHandle) sessiontype, ftponly);            /* BYU serial */
  1191.             }                                                                /* BYU 2.4.15 */
  1192.         }                                                                /* BYU serial */
  1193.         GetIText( host, config.machine);            /* BYU LSC - where do we go from here? */
  1194. #ifdef NOT                                            /* BYU LSC */
  1195.         if (*config.machine == 0)                     /* BYU LSC */
  1196.             {
  1197.             HiliteControl((ControlHandle)myHandle,255);
  1198.                     
  1199.         else 
  1200.             HiliteControl((ControlHandle)myHandle,0);
  1201. #endif
  1202.         }
  1203.  
  1204.     modalItems = 0;        /* BYU serial - disable modal cmd key feature */
  1205.  
  1206.     if (dItem==DLOGCancel) {
  1207.             DisposPtr( config.name);                /* Don't need this if we throw it out */
  1208.             DisposPtr( config.machine);            /* D I T T O ........................ */
  1209.             DisposDialog( dtemp);
  1210.             return;
  1211.             }
  1212.  
  1213.     GetIText( host, config.machine);            /* BYU LSC - where do we go from here? */
  1214.     p2cstr((unsigned char *) config.machine);    /* BYU LSC */
  1215.  
  1216. /* NCSA:    now that we have the name of the host, check to see if it
  1217.              is really just an alias.  If it is, then give us the REAL
  1218.             name, along with the port number tacked on to the end. */
  1219.  
  1220.     if (GetDataFromAlias(config.machine, &theAliasRec) ==1)
  1221.         {
  1222.         char junk[10];
  1223.         
  1224.         strcpy(config.machine,theAliasRec.name);
  1225.         sprintf (junk," %d",theAliasRec.port);
  1226.         strcat(config.machine,junk);
  1227.         }
  1228.  
  1229.     GetIText( name, config.name);                /* BYU LSC - And what is its name ...  */
  1230.     p2cstr((unsigned char *) config.name);        /* BYU LSC */
  1231.  
  1232.     if ( *config.name == 0 ) {
  1233. #if 1                                            /* BYU LSC */
  1234.         strcpy(config.name,config.machine);        /* BYU LSC */
  1235. #else                                            /* BYU LSC */
  1236.         GetIText( host, config.name);            /* BYU LSC - Copy the host name in ... */
  1237. #endif
  1238.         sprintf(aTempStr," %i",(int)numWind);
  1239.         strcat(config.name,aTempStr);
  1240.         } 
  1241.  
  1242.     for (i=0;config.machine[i];i++)
  1243.         if (!isprint(config.machine[i])) config.machine[0]=0;
  1244.             
  1245.     if ( *config.machine == 0 && !serialonly) {        /* BYU 2.4.18 */
  1246.             DisposPtr( config.name);                /* Don't need this if we throw it out */
  1247.             DisposPtr( config.machine);            /* D I T T O ........................ */
  1248.             DisposDialog( dtemp);
  1249.             return;
  1250.         }
  1251.     DisposDialog( dtemp);
  1252.  
  1253.     updateCursor(1);
  1254.     
  1255. #if 0                                            /* BYU LSC - was "ifndef MPW" */
  1256.     p2cstr((unsigned char *) config.machine);    /* BYU LSC */
  1257. #endif
  1258.     primeConfig( &config);
  1259.     if (theFtpFlag) config.ftpwind =1;
  1260.  
  1261.     if (dItem == 3)            /* Reconfigure port if applicable */
  1262.         if (!configport( &config)) {
  1263.             DisposPtr(config.name);
  1264.             DisposPtr(config.machine);
  1265.             return;
  1266.             }
  1267.     config.connectionType = serialonly;            /* BYU 2.4.15 */
  1268.  
  1269.     config.ftpstate = ftponly;        /* BYU */
  1270.     if (ftponly != 0) {                /* BYU */
  1271.         config.halfdup = 1;            /* BYU */
  1272.         }                            /* BYU */
  1273.  
  1274.     putln("Going addport");
  1275.     oldscrn=addport( &config );    /* Make our user window */
  1276.     numWind++;
  1277.     
  1278.     if (oldscrn<0) {
  1279.         DisposPtr(config.name);
  1280.         DisposPtr(config.machine);
  1281.         return;
  1282.         }
  1283. } /* setupport */
  1284.  
  1285. int ReallyClose
  1286.   (
  1287.     int scrn
  1288.   )
  1289. {
  1290.     DialogPtr dtemp;
  1291.     short item;
  1292.     char myname[256];        /* BYU LSC */
  1293.  
  1294.     SetCursor(normcurs);
  1295.  
  1296.     strcpy(myname,screens[scrn].name);        /* BYU LSC */
  1297.     c2pstr(myname);                            /* BYU LSC */
  1298.     ParamText(myname,0L,0L,0L);                /* BYU LSC */
  1299.     dtemp = GetNewDialog( CloseDLOG,(Ptr) 0L,(WindowPtr) -1L);
  1300.     UItemAssign( dtemp, 3,(int (*)())  OutlineItem);
  1301.  
  1302.     item = DLOGCancel +1;
  1303.  
  1304.     while (item> DLOGCancel)
  1305.         ModalDialog((ModalFilterProcPtr) modalProc, &item);
  1306.  
  1307.     DisposDialog( dtemp);
  1308.  
  1309.     updateCursor(1);
  1310.     
  1311.     if (item ==DLOGCancel) {
  1312.         return(0);
  1313.         }    
  1314.  
  1315.     return(1);
  1316. }
  1317.  
  1318. void LoadCONF
  1319.   (
  1320.     void
  1321.   )
  1322. {
  1323.     SFReply sfr;
  1324.     long typesok='CONF';
  1325.     Point where;
  1326.  
  1327.     where.h=100;where.v=100;
  1328. #ifndef MPW
  1329.     SFGetFile( where, "\PSet to load:", 0L, 1, &typesok,    /* BYU LSC */
  1330.                     0L, &sfr);
  1331. #else
  1332.     SFGetFile( pass(where), "Set to load:", 0L, 1, (SFTypeList) &typesok,
  1333.                     0L, &sfr);
  1334. #endif MPW
  1335.  
  1336.  
  1337.     if (! sfr.good)
  1338.         return;
  1339.  
  1340.     SetVol(0L, sfr.vRefNum);        /* BYU LSC */
  1341.     p2cstr(&sfr.fName);
  1342.     readconfig((char *) &sfr.fName);
  1343.     setmydir();                /* restore default dir for FTP */
  1344. }
  1345.  
  1346.  
  1347. CStringToFile(short myfile, unsigned char *mystring) {    /* BYU LSC */
  1348. long mycount;                                        /* BYU LSC */
  1349. short fstatus;                                        /* BYU LSC */
  1350.   mycount = strlen((char *) mystring);                /* BYU LSC */
  1351.   fstatus = FSWrite(myfile,&mycount,mystring);        /* BYU LSC */
  1352. }
  1353.  
  1354.  
  1355. void SaveCONF
  1356.   (
  1357.     void
  1358.   )
  1359.   {
  1360.     SFReply sfr;
  1361. #if 1                                    /* BYU LSC */
  1362.     short fn,fstatus;                    /* BYU LSC */
  1363. #else                                    /* BYU LSC */
  1364.     FILE *fp;
  1365. #endif                                    /* BYU LSC */
  1366.     WindowPeek wpeek;
  1367.     Rect rect;
  1368.     Point where;
  1369.     char temp[256],temp2[256];            /* BYU LSC */
  1370.     unsigned int red,green,blue;
  1371.     int fnum,fsiz;
  1372.     int i;
  1373.  
  1374.     where.h = 100; where.v = 100;
  1375. #ifndef MPW
  1376.     SFPutFile( where, "\PSave Set to:", "\PTelnet Set", 0L, &sfr);    /* BYU LSC */
  1377. #else
  1378.     SFPutFile( pass(where), "Save Set to:", "Telnet Set", 0L, &sfr);
  1379. #endif
  1380.  
  1381.     if (! sfr.good)
  1382.         return;
  1383.  
  1384.     SetVol(0L, sfr.vRefNum);                            /* BYU LSC */
  1385. /*    p2cstr(&sfr.fName);                                    /* BYU LSC */
  1386.     Create(sfr.fName, sfr.vRefNum, creator, filetype);    /* BYU LSC */
  1387.  
  1388. #if 1                                                    /* BYU LSC */
  1389.     fstatus = FSOpen(sfr.fName, sfr.vRefNum, &fn);        /* BYU LSC */
  1390. #else                                                    /* BYU LSC */
  1391.     p2cstr(sfr.fName);                                    /* BYU LSC */
  1392.     fp = fopen((char *) sfr.fName, "w");                /* BYU LSC */
  1393. #endif                                                    /* BYU LSC */
  1394.  
  1395.     if (whichMenus)
  1396.         CStringToFile(fn,(unsigned char *) "commandkeys = yes\015");    /* BYU LSC */
  1397.     else
  1398.         CStringToFile(fn,(unsigned char *) "commandkeys = no\015");        /* BYU LSC */
  1399.  
  1400.     for (i = 0; i < 10; i++)
  1401.       {
  1402.         getmacro(i, (unsigned char *) temp);            /* BYU LSC */
  1403.         if (*temp) {                                    /* BYU LSC */
  1404.             sprintf(temp2, "key%d = \"", i);            /* BYU 2.4.16 */
  1405.             strcat(temp2,temp);                            /* BYU LSC */
  1406.             strcat(temp2,"\"\015");                        /* BYU LSC */
  1407.             CStringToFile(fn,(unsigned char *) temp2);    /* BYU LSC */
  1408.         }                                                /* BYU LSC */
  1409.       } /* for */
  1410.  
  1411. #if 0                                                    /* BYU LSC */
  1412.     for (i = 0; i < numwindows; i++)
  1413.       {
  1414.         int j;
  1415.         j = RSgetfont(screens[i].vs, &fnum, &fsiz);
  1416.         sprintf(temp,"code: %d. Window %d has fnum,fsize = %d, %d",j,i,fnum,fsiz);
  1417.         putln(temp);
  1418.       } /* for */
  1419. #endif                                                    /* BYU LSC */
  1420.  
  1421.     for (i = 0; i < numwindows; i++)
  1422.       {
  1423.         sprintf(temp2, "name= \"%s\"\015", screens[i].name);    /* BYU LSC */
  1424.         CStringToFile(fn,(unsigned char *) temp2);                /* BYU LSC */
  1425.  
  1426.         sprintf(temp2, "host= \"%s\"\015", screens[i].machine);    /* BYU LSC */
  1427.         CStringToFile(fn,(unsigned char *) temp2);                    /* BYU LSC */
  1428.  
  1429.         if (screens[i].connectionType == 1)                            /* BYU 2.4.15 */
  1430.             CStringToFile(fn,(unsigned char *)  "serial= yes\015");    /* BYU 2.4.15 */
  1431.         else if (screens[i].ftpstate != 0)                            /* BYU 2.4.15 */
  1432.             CStringToFile(fn,(unsigned char *)  "ftp= yes\015");    /* BYU mod */
  1433.  
  1434.         sprintf (temp2,"port= %d\015",screens[i].portNum);    /* NCSA: save port # */
  1435.         CStringToFile(fn,(unsigned char *) temp2);                        /* BYU LSC */
  1436.  
  1437.         sprintf(temp2, "scrollback= %d\015", (screens[i].maxscroll));    /* BYU LSC */
  1438.         CStringToFile(fn,(unsigned char *) temp2);                        /* BYU LSC */
  1439.  
  1440.         if (screens[i].bsdel)
  1441.             CStringToFile(fn,(unsigned char *)  "erase = delete\015");        /* BYU LSC */
  1442.         else
  1443.             CStringToFile(fn,(unsigned char *)  "erase = backspace\015");    /* BYU LSC */
  1444.  
  1445.         wpeek = (WindowPeek) screens[i].wind;
  1446.         rect = (*wpeek->contRgn)->rgnBBox;
  1447.  
  1448.         sprintf(temp2, "size = {%d,%d,%d,%d}\015", rect.top, rect.left,    /* BYU LSC */
  1449.                     rect.bottom, rect.right);
  1450.         CStringToFile(fn,(unsigned char *) temp2);                        /* BYU LSC */
  1451.  
  1452.         sprintf(temp2, "vtwidth = %d\015", screens[i].width);            /* BYU LSC */
  1453.         CStringToFile(fn,(unsigned char *) temp2);                        /* BYU LSC */
  1454.  
  1455.         if (screens[i].tekclear)
  1456.             CStringToFile(fn,(unsigned char *) "tekclear = yes\015");    /* BYU LSC */
  1457.         else
  1458.             CStringToFile(fn,(unsigned char *) "tekclear = no\015");    /* BYU LSC */
  1459.  
  1460.         if (HasColor)
  1461.           {
  1462.             int j;
  1463.             for (j = 0; j < 4; j++)
  1464.               {
  1465.                 RSgetcolor( screens[i].vs, j, &red, &green, &blue);
  1466.                 sprintf(temp2, "rgb%d = {%u,%u,%u}\015",            /* BYU LSC */
  1467.                     j, red, green, blue);                            /* BYU LSC */
  1468.                 CStringToFile(fn,(unsigned char *) temp2);            /* BYU LSC */
  1469.               } /* for j */
  1470.           } /* if */
  1471.         RSgetfont( screens[i].vs, &fnum, &fsiz);
  1472.         GetFontName( fnum, temp);                                    /* BYU LSC */
  1473. #ifndef MPW
  1474.         p2cstr((unsigned char *) temp);                                /* BYU LSC */
  1475. #endif
  1476.  
  1477.         sprintf( temp2, "font = \"%s\"\015", temp);                    /* BYU LSC */
  1478.         CStringToFile(fn,(unsigned char *) temp2);                    /* BYU LSC */
  1479.         sprintf( temp2, "fsize= %d\015", fsiz);                        /* BYU LSC */
  1480.         CStringToFile(fn,(unsigned char *) temp2);                    /* BYU LSC */
  1481.         
  1482.         sprintf( temp2, "nlines= %d\015", VSgetlines(screens[i].vs));/* BYU LSC */
  1483.         CStringToFile(fn,(unsigned char *) temp2);                    /* BYU LSC */
  1484.         sprintf( temp2, "keystop= %d\015", screens[i].TELstop);        /* BYU LSC */
  1485.         CStringToFile(fn,(unsigned char *) temp2);                    /* BYU LSC */
  1486.         sprintf( temp2, "keygo= %d\015", screens[i].TELgo);            /* BYU LSC */
  1487.         CStringToFile(fn,(unsigned char *) temp2);                    /* BYU LSC */
  1488.         sprintf( temp2, "keyip= %d\015", screens[i].TELip);            /* BYU LSC */
  1489.         CStringToFile(fn,(unsigned char *) temp2);                    /* BYU LSC */
  1490.         sprintf( temp2, "crmap= %d\015\015", screens[i].crmap);        /* BYU LSC */
  1491.         CStringToFile(fn,(unsigned char *) temp2);                    /* BYU LSC */
  1492.       } /* for i */
  1493.  
  1494. #if 1
  1495.     FSClose(fn);                        /* BYU LSC */
  1496. #else
  1497.     fclose(fp);
  1498. #endif
  1499.     setmydir();                            /* restore default dir for FTP */
  1500.   } /* SaveCONF */
  1501.  
  1502. /*************************************************************************/
  1503. /*  Change transfer directory for FTP
  1504. */
  1505.  
  1506. pascal short FileHook
  1507.   (
  1508.     short item,
  1509.     DialogPtr theDialog
  1510.   )
  1511. {
  1512. #pragma unused(theDialog)
  1513.     if(item == 11) {                    /* Set Directory Button */
  1514.             setdir = 1;
  1515.             
  1516.             return(3);        /* pretend we hit cancel, but we didn't */
  1517.         }
  1518.     else if (item == 12 || item == 13)
  1519.         item = 9;            /* these don't count, map to disabled item */
  1520.  
  1521.     return(item);
  1522. }
  1523.  
  1524. /*
  1525.  *    wdset - set the working directory for FTP's
  1526.  */
  1527.  
  1528. int wdset
  1529.   (
  1530.     void
  1531.   )
  1532. {
  1533.     Point where;
  1534.     SFReply reply;
  1535.  
  1536.     where.h=100;where.v=100;
  1537.     setdir = 0;                    /* clear dir found flag */
  1538.     
  1539.     setmydir();
  1540.     SFPGetFile( where, "\pDefault receive Directory", NULL, -1, NULL,    /* BYU LSC */
  1541.         (DlgHookProcPtr) FileHook, &reply, 4001,
  1542.         (ModalFilterProcPtr) modalProc); 
  1543.  
  1544.     if (setdir)                    /* we got a dir */
  1545.         setSFdir();
  1546.     else {
  1547.         if(!reply.good) return(-1);    /* real cancel button got hit */
  1548.         makemydir(reply.vRefNum);        /* chose a file */
  1549.     }
  1550.     return(0);
  1551.   } /* wdset */
  1552.  
  1553. /*
  1554.  * printGraph -    Print the graphics on the current window
  1555.  *        vg - which graphics window to print
  1556.  */
  1557.  
  1558. void printGraph
  1559.   (
  1560.     int dnum            /* Which drawing to print */
  1561.   )
  1562. {
  1563.     int h,v;            /* used for centering (h=horiz. , v=vert.) */
  1564.     int wh,wv;            /* Window horiz and vert */
  1565.     TPrStatus
  1566.         prStatus;        /* Printing status record */
  1567.     Rect prRect;        /* the rectangle to print in */
  1568.     TPPrPort prPort;    /* the printing port */
  1569.     int j;                /* VG identifier for pass-through */
  1570.     
  1571.     SetCursor(normcurs);
  1572.  
  1573.     if (PrJobDialog(prRecHdl)) {            /* Cancel the print if FALSE */
  1574.         prPort=PrOpenDoc(prRecHdl,0L,0L);        /* Open Printer Port */
  1575.             if (PrError() == 0)    {                /* If we can't, then die */
  1576.                 PrOpenPage(prPort, 0L);                /* Open a page */
  1577.  
  1578.                 (*prRecHdl)->prJob.pIdleProc = (PrIdleProcPtr) printsleep;    /* our sleep/cancel*/
  1579.  
  1580.                 prRect=PGRECT;                        /* Get the page rectangle */
  1581.                 h=prRect.right - prRect.left;    /* Get the width */
  1582.                 v=prRect.bottom- prRect.top;    /* Get the height */
  1583.                 if (3*h<4*v) {                    /* Center the little bugger */
  1584.                     wh = h;
  1585.                     wv = (3 * h)/ 4;
  1586.                     }
  1587.                 else {                            /* On the page rectangle */
  1588.                     wv = v;
  1589.                     wh = (4 * v)/ 3;
  1590.                     }
  1591.         
  1592.                 prRect.top  = (v- wv) /2;
  1593.                 prRect.left = (h- wh) /2;
  1594.                 prRect.bottom = prRect.top + wv;
  1595.                 prRect.right = prRect.left + wh;
  1596.  
  1597.                 j=VGnewwin(3,0);                    /* create pass-through port */
  1598.                 RGMPsize( &prRect );
  1599.                 VGzcpy( dnum, j);                /* Love dat zm factr */
  1600.                 VGredraw(dnum,j);                /* Copy the picture in i to j */
  1601.                 VGclose(j);                        /* OK, we're done, give it to someone else */
  1602.                 PrClosePage(prPort);            /* Page out.... */
  1603.                 }
  1604.  
  1605.             PrCloseDoc(prPort);                    /* Done with the document */
  1606.             putln("Doc is closed... the printing begins....");
  1607.  
  1608. #if 1                                                                        /* BYU 2.4.20 */
  1609.         if (PrError()==0)                                                    /* BYU 2.4.20 - changed for HP DeskWriter*/
  1610. #else                                                                        /* BYU 2.4.20 */
  1611.         if (((*prRecHdl)->prJob.bJDocLoop == bSpoolLoop) && (PrError()==0))
  1612. #endif                                                                        /* BYU 2.4.20 */
  1613.             PrPicFile(prRecHdl,0L,0L,0L,&prStatus);
  1614.                                     /* Print the spooled file if applicable */
  1615.     }        /* if PrJobDialog */
  1616.     
  1617.     updateCursor(1);
  1618. }
  1619.  
  1620. /*
  1621.  *    printPages(prPort,charh,title, columns) -
  1622.  *            Prints <charh> on the printer through port <prPort> with <title>
  1623.  *            using <columns>.
  1624.  */
  1625. void printPages
  1626.   (
  1627.     TPPrPort prPort,        /* the Printer port */
  1628.     char **charh,
  1629.     Str255 *Title,
  1630.     int columns,
  1631.     int theScreen
  1632.   )
  1633. {
  1634.     char *charp, *start;
  1635.     long charlen,count=0L;
  1636.     int v,h,vloc,scount=0, lines=0, pgcount=1, pgtmplen, maxlines;
  1637.     char pagetemp[20];
  1638.     FMetricRec info;
  1639.     Fixed columnF;
  1640.     int Fheight, Fwidth;
  1641.     int ww;
  1642.  
  1643.     if ( ((*prRecHdl)->prStl.wDev>>8) !=3 ) {
  1644.                     /* Think about this: put def. font in rsrc fork- STR255 */
  1645.         TextFont(4);                        /* MONACO */
  1646.         v=9;
  1647.         }
  1648.     else {
  1649.         TextFont(22);                        /* or courier */
  1650.         v=14;
  1651.         }
  1652.     columnF = FixRatio( columns, 1);
  1653.     TextFont((*(screens[theScreen].wind)).txFont);
  1654.     TextFace((*(screens[theScreen].wind)).txFace);
  1655.     v = (*(screens[theScreen].wind)).txSize;
  1656.  
  1657.     TextSize(v);
  1658.     FontMetrics( &info );
  1659.     Fheight = FixRound( info.ascent + info.descent + info.leading);
  1660.     Fwidth  = FixRound( info.widMax);
  1661.     Fwidth  = CharWidth('W');            /* Re-assign to largest char */
  1662.  
  1663.     v--;
  1664.     ww = TextWidth( stupidarray,0,columns);
  1665.  
  1666.  
  1667.     HLock(charh);
  1668.     start=charp=*charh;
  1669.     charlen= GetHandleSize(charh);
  1670.  
  1671.     h=PGRECT.right - PGRECT.left;    /* Get the width */
  1672.     v=PGRECT.bottom- PGRECT.top;    /* Get the height */
  1673.  
  1674.     maxlines= (v / Fheight) - 2*VMARGINS -1;        /* Get maxlines */
  1675.     vloc= VMARGINS;
  1676.  
  1677.     while (count<charlen) {
  1678.         PrOpenPage(prPort, 0L);        /* Open the Printer Page */
  1679.         (*prRecHdl)->prJob.pIdleProc = (PrIdleProcPtr) printsleep;    /* our netsleep */
  1680.  
  1681.         MoveTo( 0, (VMARGINS-2)*Fheight);
  1682.         DrawString("\pSession Name: ");            /* BYU LSC */
  1683.  
  1684.         DrawString(Title);                        /* BYU LSC */
  1685.         sprintf(pagetemp, "Page %d", pgcount);
  1686.         pgtmplen=strlen(pagetemp);
  1687.         MoveTo( h-(pgtmplen * Fwidth), (VMARGINS-2)*Fheight);
  1688.         DrawText( pagetemp, 0, pgtmplen);
  1689.         vloc=VMARGINS;
  1690.  
  1691.         while (lines < maxlines && count<charlen) {
  1692.             while ((count<charlen) && (*charp++!='\015')) { count++; scount++; }    /* BYU 2.4.18 - changed \n to \015 */
  1693.             MoveTo(0,vloc++*Fheight);
  1694.             if (scount>0)
  1695.                 DrawText(start, 0, scount);
  1696.             count++;
  1697.             lines++;
  1698.             scount=0;
  1699.             start=charp;
  1700.             }
  1701.  
  1702.         vloc=VMARGINS;
  1703.         PrClosePage(prPort);        /* Close the Printer page */
  1704.         lines=0;
  1705.         pgcount++;
  1706.         }
  1707.     HUnlock(charh);
  1708. }
  1709.  
  1710. /*
  1711.  * printText -    Print the text selected on the screen 
  1712.  *        vs - which vs to print from
  1713.  */
  1714.  
  1715. void printText
  1716.   (
  1717.     int vs,                /* Which screen to print */
  1718.     Str255 *Title,            /* The title string */
  1719.       int theScreen
  1720.   )
  1721. {
  1722.     char **charh;            /* The character handle */
  1723.     TPrStatus prStatus;        /* Status record */
  1724.     TPPrPort prPort;        /* the Printer port */
  1725.  
  1726.     charh = RSGetTextSel(vs,0);                /* Get the characters to print */
  1727.  
  1728.     if ( charh==0L)
  1729.         return;                /* don't print nothing.... */
  1730.  
  1731.     SetCursor(normcurs);
  1732.     
  1733.     if (PrJobDialog(prRecHdl)) {            /* Cancel the print if FALSE */
  1734.         prPort=PrOpenDoc(prRecHdl,0L,0L);
  1735.             if (PrError() == 0)    {
  1736.                 printPages( prPort, charh, Title, VSmaxwidth(vs),theScreen);
  1737.                                                             /* Draw the text */
  1738.                 }
  1739.             PrCloseDoc(prPort);
  1740.  
  1741.         if (((*prRecHdl)->prJob.bJDocLoop == bSpoolLoop) && (PrError()==0))
  1742.             PrPicFile(prRecHdl,0L,0L,0L,&prStatus); /* Spool the print */
  1743.                                                 /* If necessary..... */
  1744.         }
  1745.     HPurge(charh);                            /* Kill the printed chars */
  1746.     updateCursor(1);
  1747. }
  1748.  
  1749. int ReallyQuit
  1750.   (
  1751.     void
  1752.   )
  1753. {
  1754.     DialogPtr dtemp;
  1755.     short item;
  1756.  
  1757.     SetCursor(normcurs);
  1758.  
  1759.     dtemp = GetNewDialog( QuitDLOG,(Ptr) 0L,(WindowPtr) -1L);
  1760.     UItemAssign( dtemp, 3, (int (*)()) OutlineItem);
  1761.  
  1762.     item = DLOGCancel +1;
  1763.  
  1764.     while (item> DLOGCancel)
  1765.         ModalDialog((ModalFilterProcPtr) modalProc, &item);
  1766.  
  1767.     DisposDialog( dtemp);
  1768.  
  1769.     updateCursor(1);
  1770.     
  1771.     if (item ==DLOGCancel) {
  1772.         return(0);
  1773.         }    
  1774.  
  1775.     return(1);
  1776. }
  1777.  
  1778. void quit
  1779.   (
  1780.     void
  1781.   )
  1782. {
  1783.     if (numwindows>0)
  1784.         return;
  1785.  
  1786.     if (hKCHR)                        /* BYU 2.4.12 */
  1787.         ReleaseResource(hKCHR);        /* BYU 2.4.12 */
  1788.  
  1789.     if (theWorld.systemVersion < 0x0700)    /* BYU 2.4.18 */
  1790.         optionKeysOff();                    /* BYU 2.4.18 */
  1791.  
  1792.     PortClose();        /* BYU serial - make sure serial port is closed */
  1793.     netshut();
  1794.     PrClose();
  1795.     putln("got here\015");            /* BYU 2.4.18 - changed \n to \015 */
  1796.  
  1797.     if (EtherNet == -99)            /* BYU 2.4.16 */
  1798.         CloseResolver();            /* BYU 2.4.16 */
  1799.  
  1800.     close_mb_files();    /* BYU - Don't leave any files open! */
  1801.     done = 1;            /* BYU */
  1802. }
  1803.  
  1804. /* 
  1805.  * copyGraph    - Copy the current graphics screen.
  1806.  *            dnum - the number of the drawing to copy .
  1807.  */
  1808.  
  1809. void copyGraph
  1810.   (
  1811.     int dnum
  1812.   )
  1813. {
  1814.     long tlong;                    /* Temporary Variable */
  1815.     PicHandle tpic;                /* Mental picture of the thing */
  1816.  
  1817.     tpic=RGtoPICT(dnum);            /* Get the picture */
  1818.     tlong=ZeroScrap();                /* Nobody else can live here */
  1819.     HLock((Handle) tpic);                    /* Lock it for Puting */
  1820.     tlong=PutScrap(GetHandleSize((Handle) tpic),'PICT', (Ptr) *tpic);    /* Store as a PICT */
  1821.     HUnlock((Handle) tpic);                    /* Unlock so we can toss it */
  1822.     KillPicture(tpic);                /* Kill the picture..... */
  1823. }                
  1824.  
  1825. /* 
  1826.  * copyText    - Copy the current selection on the virtual screen
  1827.  *            vs - the number of the virtual screen to copy from
  1828.  */
  1829.  
  1830. void copyText
  1831.   (
  1832.     int vs
  1833.   )
  1834. {
  1835.     char **charh;            /* where to store the characters */
  1836.     long tlong;                /* Necessary temporary variable */
  1837.  
  1838.     tlong=ZeroScrap();        /* This Scrap aint big enough for the both of us */
  1839.  
  1840.     charh=RSGetTextSel(vs,0);        /* Get the text selection */
  1841.  
  1842.     if (charh!= (char **)0L && charh!= (char **)-1L) {    /* BYU LSC - Can't do anything without characters */
  1843.         HLock(charh);                /* Lock for putting */
  1844.         tlong=PutScrap(GetHandleSize(charh),'TEXT',*charh);
  1845.                                     /* Put it as a TEXT resource */
  1846.         HUnlock(charh);                /* Unlock for disposal */
  1847.         DisposHandle(charh);        /* Kill the chars */
  1848.         }
  1849.     else putln("No characters to copy darn it!");
  1850. }
  1851.  
  1852. /* 
  1853.  * copyTable   - Copy the current selection on the virtual screen
  1854.  *            vs - the number of the virtual screen to copy from
  1855.  */
  1856.  
  1857. void copyTable
  1858.   (
  1859.     int vs
  1860.   )
  1861. {
  1862.     char **charh;            /* where to store the characters */
  1863.     long tlong;                /* Necessary temporary variable */
  1864.  
  1865.     tlong=ZeroScrap();        /* This Scrap aint big enough for the both of us */
  1866.  
  1867.     charh=RSGetTextSel(vs, Prefs.CTthresh);        /* Get the text selection */
  1868.  
  1869.     if (charh>(char **)0L) {                    /* BYU LSC - Can't do anything without characters */
  1870.         HLock(charh);                /* Lock for putting */
  1871.         tlong=PutScrap(GetHandleSize(charh),'TEXT',*charh);
  1872.                                     /* Put it as a TEXT resource */
  1873.         HUnlock(charh);                /* Unlock for disposal */
  1874.         DisposHandle(charh);        /* Kill the chars */
  1875.         }
  1876.     else putln("No characters to copy darn it!");
  1877. }
  1878.  
  1879. /*
  1880.  *    paste - Paste the resource from the scrap into the current WIND, if
  1881.  *            and only if it is really text
  1882.  */
  1883.  
  1884. void paste
  1885.   (
  1886.     void
  1887.   )
  1888. {
  1889.     long
  1890. #if 0                        /* BYU LSC - was "#ifndef MPW" */
  1891.         GetScrap(),            /* We must cast the Brother */
  1892. #endif
  1893.         off,                /* offset */
  1894.         length;                /* the lenght of what is on the Scrap */
  1895.  
  1896.     /* Flush the buffer if we have echo */
  1897.     
  1898.     if ((screens[scrn].ftpstate == 0) &&    /* BYU */
  1899.         screens[scrn].echo &&                 /* BYU */
  1900.         screens[scrn].kblen>0) {            /* BYU */
  1901.         netwrite( screens[scrn].port, screens[scrn].kbbuf,
  1902.                     screens[scrn].kblen);    /* if full send buffer */
  1903.         screens[scrn].kblen=0;
  1904.         }
  1905.  
  1906.     if (GetScrap(0L, 'TEXT', &off)<=0L)        /* If there are no TEXT res's */
  1907.             { putln("No text on scrap");
  1908.             return;                        /* then we can't paste it */
  1909.             }
  1910.  
  1911.     screens[scrn].outhand=NewHandle(0L);    /* create a handle to put chars in */
  1912.  
  1913.     length= GetScrap( screens[scrn].outhand, 'TEXT',&off);
  1914.                                             /* Store the scrap into the handle */
  1915.     screens[scrn].outlen = length;            /* Set the length */
  1916.     HLock(screens[scrn].outhand);            /* Lock the Handle down for safety */
  1917.     screens[scrn].outptr=*screens[scrn].outhand;    /* Set the pointer */
  1918.     if (screens[scrn].clientflags & PASTE_IN_PROGRESS)    /* BYU LSC */
  1919.         SysBeep(4);            /* BYU LSC */
  1920.     else {                    /* BYU LSC */
  1921.         screens[scrn].clientflags |= PASTE_IN_PROGRESS;
  1922.         screens[scrn].incount = 0;
  1923.         screens[scrn].outcount = 0;
  1924.         pasteText( scrn);    /* BYU LSC - routine to paste to net, w/echo if neccessary */
  1925.     }
  1926. }
  1927.  
  1928. void Macros
  1929.   (
  1930.     void
  1931.   )
  1932. {
  1933.     DialogPtr dtemp;
  1934.     short dItem;
  1935.     int i;
  1936.     Rect dBox;
  1937.     Str255 temp;
  1938.     Handle MacString[10];
  1939.  
  1940.     SetCursor(normcurs);
  1941.  
  1942.     dtemp=GetNewDialog( MacroDLOG,(Ptr) 0L,(WindowPtr) -1L);    /* Bring on the box */
  1943.     UItemAssign( dtemp, 23 , (int (*)()) OutlineItem);
  1944.  
  1945.     for (i=0; i<10; i++) {
  1946.         getmacro( i, (unsigned char *) &temp);        /* BYU LSC */
  1947.         c2pstr(temp);                                /* BYU LSC */
  1948.         GetDItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
  1949.         SetIText( MacString[i], &temp );            /* BYU LSC */
  1950.         }
  1951.  
  1952.     dItem=0;                                /* initially no hits */
  1953.     while((dItem>2) || (dItem==0)) {        /* While we are in the loop */
  1954.         ModalDialog((ModalFilterProcPtr) modalProc,&dItem);    /* and do our duty to the box */
  1955.         if (dItem >2 && dItem <13) {
  1956.             i=dItem-3;
  1957.             getmacro( i, (unsigned char *) &temp);            /* BYU LSC */
  1958.             c2pstr(temp);                                    /* BYU LSC */
  1959.             GetDItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
  1960.             SetIText( MacString[i], &temp );                /* BYU LSC - Revert the mother */
  1961.             SelIText( dtemp, i+13, 0, 32767);                /* And select it... */
  1962.             }
  1963.         }
  1964.         
  1965.     updateCursor(1);
  1966.     
  1967.     if (dItem==DLOGCancel) {
  1968.             DisposDialog( dtemp);
  1969.             return;
  1970.             }
  1971.  
  1972.     for (i=0; i<10; i++) {
  1973.         GetIText( MacString[i], &temp);                /* BYU LSC */
  1974.         p2cstr(temp);                                /* BYU LSC */
  1975.         setmacro(i, (unsigned char *) &temp);        /* BYU LSC */
  1976.         }
  1977.  
  1978.     DisposDialog( dtemp);
  1979. }
  1980.  
  1981. void displayStatus
  1982.   (
  1983.     int n,
  1984.     int active
  1985.   )
  1986. {
  1987.     DialogPtr dtemp;
  1988.     short item;
  1989.     Str255 statusstring;        /* BYU LSC */
  1990.  
  1991.     SetCursor(normcurs);
  1992.  
  1993. #ifndef MPW
  1994.     strcpy((char *) statusstring,screens[n].machine);        /* BYU LSC */
  1995.     c2pstr(statusstring);                                    /* BYU LSC */
  1996.     if (screens[n].corpse) {
  1997.         ParamText( statusstring,"\Pis awaiting dismissal",0L,0L);    /* BYU LSC */
  1998.         }
  1999.     else {
  2000.         if (active <0) {
  2001.                 ParamText( statusstring,"\Pbeing looked up",0L,0L);    /* BYU LSC */
  2002.             }
  2003.         else {
  2004.             ParamText( statusstring,"\Pbeing opened", 0L, 0L);        /* BYU LSC */
  2005.             }
  2006.         }
  2007. #else
  2008.     if (screens[n].corpse) {
  2009.         ParamText( screens[n].machine,"is awaiting dismissal",0L,0L);        /* BYU LSC */
  2010.         }
  2011.     else {
  2012.         if (active <0) {
  2013.                 ParamText( screens[n].machine,"being looked up",0L,0L);        /* BYU LSC */
  2014.             }
  2015.         else {
  2016.             ParamText( screens[n].name,"being opened", 0L, 0L);                /* BYU LSC */
  2017.             }
  2018.         }
  2019. #endif
  2020.  
  2021.     dtemp=GetNewDialog( StatusDLOG,(Ptr) 0L,(WindowPtr) -1L);    /* Bring on the box */
  2022.     UItemAssign( dtemp, 3, (int (*)()) OutlineItem);
  2023.  
  2024.     item =DLOGCancel+1;
  2025.     while (item> DLOGCancel)
  2026.         ModalDialog((ModalFilterProcPtr) modalProc, &item);
  2027.  
  2028.     updateCursor(1);
  2029.     
  2030.     if (item ==DLOGCancel) {
  2031.         netclose(screens[n].port);
  2032.         destroyport( n);
  2033.         }    
  2034.  
  2035.     DisposDialog( dtemp);
  2036. }
  2037.  
  2038. /*
  2039.  *    changeport - handle the menu updates for changing from one port to another
  2040.  */
  2041. void changeport
  2042.   (
  2043.     int oldprt,
  2044.     int newprt
  2045.   )
  2046. {
  2047.  
  2048.     sprintf(tempspot,"oldscrn: %d, newscrn: %d",oldprt,newprt); putln(tempspot);
  2049.     
  2050.     if (screens[oldprt].active==0) 
  2051.         CheckItem(myMenus[Conn], oldprt+3,FALSE);        /* Adjust Conn menu */
  2052.     CheckItem(myMenus[Conn], newprt+3,TRUE);
  2053.  
  2054.     CheckItem(myMenus[Emul], EMbs,FALSE);                        /* Adjust BS */
  2055.     CheckItem(myMenus[Emul], EMdel,FALSE);
  2056.     CheckItem(myMenus[Emul], EMbs+screens[newprt].bsdel,TRUE);    /* and DEL */
  2057.  
  2058.     if (screens[newprt].ESclear)                /* BYU 2.4.8 */
  2059.         CheckItem(myMenus[Emul],EMclear,TRUE);    /* BYU 2.4.8 */
  2060.     else                                         /* BYU 2.4.8 */
  2061.         CheckItem(myMenus[Emul],EMclear,FALSE);    /* BYU 2.4.8 */
  2062.  
  2063.     if (screens[newprt].ESscroll)
  2064.         CheckItem(myMenus[Emul],EMscroll,TRUE);
  2065.     else 
  2066.         CheckItem(myMenus[Emul],EMscroll,FALSE);
  2067.  
  2068.     if (screens[newprt].echo)                     /* LOCAL ECHO */
  2069.         CheckItem(myMenus[Emul],EMecho,TRUE);
  2070.     else                                         /* REMOTE ECHO */
  2071.         CheckItem(myMenus[Emul],EMecho,FALSE);
  2072.         
  2073.     if (screens[newprt].wrap)                     /* wrap on */
  2074.         CheckItem(myMenus[Emul],EMwrap,TRUE);
  2075.     else                                         /* wrap off */
  2076.         CheckItem(myMenus[Emul],EMwrap,FALSE);
  2077.  
  2078.     if (VSiscapturing(screens[newprt].vs))                /* BYU 2.4.18 */
  2079.         CheckItem(myMenus[Emul], EMcapture,TRUE);        /* BYU 2.4.18 */
  2080.     else                                                /* BYU 2.4.18 */
  2081.         CheckItem(myMenus[Emul], EMcapture,FALSE);        /* BYU 2.4.18 */
  2082.  
  2083.     scrn=newprt;
  2084.  
  2085.     SLIP_menus();                            /* BYU 2.4.15 */
  2086.  
  2087.     CheckFonts();
  2088. }
  2089.  
  2090. /*
  2091.  * showNetNumbers    - Show the current network numbers.
  2092.  */
  2093. #define STR_BASE 0            /* BYU LSC */
  2094.  
  2095. void showNetNumbers
  2096.   (
  2097.     void
  2098.   )
  2099. {
  2100.     char tmpout[30],        /* IP Number */
  2101.         tmpout2[75];        /* Aux. Information */
  2102.     DialogPtr dtemp;        /* dialog box pointer */
  2103.     int i,                    /* Looping Var */
  2104.         tmp[4];                /* Integer copy of IP Number */
  2105.     
  2106.     for(i=0; i<4; i++)
  2107.             tmp[i]=(int)myipnum[i];        /* Get integer numbers */
  2108.  
  2109.     if (dynamic) {
  2110.         if (EtherNet)
  2111.             sprintf(&tmpout[STR_BASE],"%d.%d.%d.%d [RARP]",tmp[0],tmp[1],tmp[2],tmp[3]);
  2112.         else
  2113.             sprintf(&tmpout[STR_BASE],"%d.%d.%d.%d [KIP]",tmp[0],tmp[1],tmp[2],tmp[3]);
  2114.         }
  2115.     else
  2116.         sprintf(&tmpout[STR_BASE],"%d.%d.%d.%d",tmp[0],tmp[1],tmp[2],tmp[3]);
  2117.                                         /* create Human-readable numbers */
  2118.  
  2119.     if (EtherNet==-99)
  2120.         sprintf( &tmpout2[STR_BASE], "Driver MacTCP");
  2121.     else
  2122.     if (EtherNet) 
  2123.         sprintf( &tmpout2[STR_BASE], "EtherNet %x:%x:%x:%x:%x:%x\rSlot: %d\rSubnet Mask:%lx",    /* BYU 2.4.8 */
  2124.             (int)nnmyaddr[0],  (int)nnmyaddr[1],  (int)nnmyaddr[2], 
  2125.             (int)nnmyaddr[3],  (int)nnmyaddr[4],  (int)nnmyaddr[5],
  2126.             EtherNet,mynetmask); 
  2127.     else 
  2128.         sprintf(&tmpout2[STR_BASE],"Appletalk Net: %d\rAppletalk Node: %d\rSubnet Mask:%lx",    /* BYU 2.4.8 */
  2129.                             (int)nnmyaddr[0]*0x100+(int)nnmyaddr[1],
  2130.                             (int)nnmyaddr[2], mynetmask);
  2131.  
  2132.     c2pstr(tmpout);                                    /* BYU LSC */
  2133.     c2pstr(tmpout2);                                /* BYU LSC */
  2134.     ParamText(0L,tmpout,0L,tmpout2);                /* BYU LSC - Put Parms in Dlog */
  2135.     
  2136.     dtemp=GetNewDialog(259,(Ptr) 0L,(WindowPtr) -1L);        /* Get Dialog */
  2137.     DrawDialog(dtemp);                                /* Display Dialog */
  2138.  
  2139.     Wait4Mouse();                                    /* Wait for a click */
  2140.  
  2141.     DisposDialog(dtemp);                            /* kill it, kill it */
  2142. }
  2143.  
  2144. int PromptBadDynamic
  2145.   (
  2146.     void
  2147.   )
  2148. {
  2149.     DialogPtr dtemp;
  2150.     short item;
  2151.  
  2152. #ifndef MPW
  2153.     ParamText(0L,"\Pobtain dynamic",0L,0L);            /* BYU LSC */
  2154.     if (EtherNet) {
  2155.         ParamText( "\PRARP",0L,0L,0L);                /* BYU LSC */
  2156.         }
  2157.     else {
  2158.         ParamText( "\PKIP",0L,0L,0L);                /* BYU LSC */
  2159.         if (!dynamic) 
  2160.             ParamText(0L,"\Pregister static",0L,0L);    /* BYU LSC */
  2161.         }
  2162. #else
  2163.     ParamText(0L,"obtain dynamic",0L,0L);            /* BYU LSC */
  2164.     if (EtherNet) {
  2165.         ParamText( "RARP",0L,0L,0L);                /* BYU LSC */
  2166.         }
  2167.     else {
  2168.         ParamText( "KIP",0L,0L,0L);                    /* BYU LSC */
  2169.         if (!dynamic) 
  2170.             ParamText(0L,"register static",0L,0L);    /* BYU LSC */
  2171.         }
  2172. #endif MPW
  2173.  
  2174.     dtemp=GetNewDialog( BadDynDLOG,(Ptr) 0L,(WindowPtr) -1L);    /* Bring on the box */
  2175.     UItemAssign( dtemp, 3, (int (*)()) OutlineItem);
  2176.  
  2177.     item =DLOGCancel+1;
  2178.     while (item> DLOGCancel)
  2179.         if (item ==5) {
  2180.             DisposDialog(dtemp);
  2181.             return(-1);
  2182.             }
  2183.         else ModalDialog((ModalFilterProcPtr) modalProc, &item);
  2184.  
  2185.     DisposDialog( dtemp);
  2186.  
  2187.     if (item ==DLOGCancel) {
  2188.         return(0);
  2189.         }    
  2190.  
  2191.     return(1);
  2192. }
  2193.  
  2194. void reconfigNetwork
  2195.   (
  2196.     int warning
  2197.   )
  2198. {
  2199.     int again=1;
  2200.     int error=1;
  2201.  
  2202.     if (warning)
  2203.         again = PromptBadDynamic();
  2204.  
  2205.     if (again<0) {                        /* REMOVE THIS SOON! */
  2206.         error=0;
  2207.         again=0;
  2208.         }
  2209.     while (again) {
  2210.         again=0; error=0;
  2211.         if ( PromptIP( dynamic)) {
  2212.             if (KIP) {
  2213.                 DynamIP((char *) myipnum);        /* BYU LSC - KIP Dynamic IP Numbers */
  2214.                 error = RegIP((char *) myipnum);    /* BYU LSC */
  2215.                 }
  2216.             else {
  2217.                 netsetip((unsigned char *) "RARP");        /* BYU LSC - RARP Dynamic IP Numbers -ET */
  2218.                 error = netgetrarp();
  2219.                 netgetip(myipnum);
  2220.                 }
  2221.     
  2222.             if (!(myipnum[0] & 0x80))
  2223.                     defmask=0xff000000;                        /* Class A */
  2224.                 else if ( (myipnum[0] & 0xC0 )==0x80)
  2225.                     defmask=0xffff0000;                        /* Class B */
  2226.                 else if ( (myipnum[0] & 0xC0 )==0xC0)
  2227.                     defmask=0xffffff00;                        /* Class C */
  2228.             if (!cmask) mynetmask=defmask;
  2229.             dynamic=1;
  2230.             }
  2231.         else {
  2232.             dynamic =0;
  2233.             error = RegIP((char *) myipnum);        /* BYU LSC */
  2234.             }
  2235.         if (error)
  2236.             again=PromptBadDynamic();
  2237.         }
  2238.  
  2239.     if (error)
  2240.         quit();
  2241.     else {
  2242.         setnetconfigs((char *) myipnum,  &mynetmask);    /* BYU LSC - Assign the new mask and IP numbers */
  2243.         netarpme((char *) myipnum);                        /* BYU LSC - Anyone Else using my IP Number? */
  2244.     
  2245.         Ssetgates();            /* finishes IP inits */
  2246.         }
  2247. }
  2248.  
  2249. void LinesPlease
  2250.   (
  2251.     int scrn
  2252.   )
  2253. {
  2254.     DialogPtr dtemp;
  2255.     Rect dBox;
  2256.     short dItem;
  2257.     Handle lines;
  2258.     char strlines[50];
  2259.     int    numlines,notgood;
  2260.  
  2261.     
  2262.     dtemp=GetNewDialog( LinesDLOG,(Ptr) 0L,(WindowPtr) -1L); /* Bring on the box */
  2263.     UItemAssign( dtemp, 3, (int (*)()) OutlineItem);        /* Default is #3 [OK] */
  2264.     
  2265.     SetCursor(normcurs);
  2266.  
  2267.     notgood = 1;
  2268.     sprintf( strlines, "%d", VSgetlines( screens[scrn].vs) );
  2269.     c2pstr(strlines);                                /* BYU LSC */
  2270.     GetDItem( dtemp, LinesNumber, &dItem, &lines, &dBox);    /* Install the default host */
  2271.  
  2272.     while (notgood) {
  2273.         notgood = 0;                                /* Default to good */
  2274.         SetIText( lines , strlines);                /* BYU LSC */
  2275.         SelIText( dtemp, LinesNumber, 0, 32767);    /* And select it... */
  2276.     
  2277.         dItem=0;                                /* initially no hits */
  2278.         while((dItem>3) || (dItem==0))            /* While we are in the loop */
  2279.             ModalDialog((ModalFilterProcPtr) modalProc,&dItem); /* and do our duty to the box */
  2280.     
  2281.         if (dItem==DLOGCancel) {
  2282.             DisposDialog( dtemp);
  2283.             return;
  2284.             }
  2285.         
  2286.         GetIText( lines, strlines);            /* BYU LSC - Get the string */
  2287.         p2cstr(strlines);                    /* BYU LSC */
  2288.         sscanf( strlines, "%d", &numlines);    /* Get the number */
  2289.         
  2290.         if (numlines <10) {
  2291.             numlines = 10;
  2292.             SysBeep(5);
  2293.             notgood=1;
  2294.         } else if (numlines > 200) {
  2295.             numlines = 200;
  2296.             SysBeep(5);
  2297.             notgood=1;
  2298.             }
  2299.         }
  2300.     DisposDialog( dtemp);
  2301.     
  2302.     VSsetlines( screens[scrn].vs, numlines);
  2303.     RSsize( screens[scrn].wind, NULL, 0);
  2304.  
  2305.     if (screens[scrn].naws)             /* NCSA: send size of window to server */
  2306.         {                                /* NCSA */
  2307.         char parsedat[20];                /* NCSA */        
  2308.         netpush (screens[scrn].port);    /* NCSA */
  2309.  
  2310. /* NCSA: syntax for command is:  IAC SB NAWS widthHI widthLO heightHI heightLO IAC SE */
  2311.  
  2312.         sprintf(parsedat,"%c%c%c%c%c%c%c%c%c",255,250,31,(char)0    /* NCSA */
  2313.             ,(char)screens[scrn].width,(char)0,numlines,255,240);    /* NCSA */
  2314.         netwrite(screens[scrn].port,parsedat,9);                    /* NCSA: send data */        
  2315.         }
  2316.  
  2317.     updateCursor(1);
  2318. }
  2319.  
  2320. /*******************************************************************/
  2321. /*  setupkeys
  2322. *   Prompt the user for which keys to use for kill, stop and start.
  2323. */
  2324. #define killbox 5
  2325. #define stopbox 6
  2326. #define startbox 7
  2327.  
  2328. void setupkeys
  2329.   (
  2330.     void
  2331.   )
  2332. {
  2333.     DialogPtr dtemp;
  2334.     Rect dBox;
  2335.     short dItem,kItem,sItem,eItem;
  2336.     Handle kbox,sbox,ebox;
  2337.     
  2338.     dtemp=GetNewDialog( SetupDLOG,(Ptr) 0L,(WindowPtr) -1L);    /* Bring on the box */
  2339.     UItemAssign( dtemp, 3, (int (*)()) OutlineItem);            /* Default is #3 [OK] */
  2340.  
  2341.     SetCursor(normcurs);
  2342.     
  2343.     GetDItem( dtemp, killbox, &kItem, &kbox, &dBox);    
  2344.     GetDItem( dtemp, stopbox, &eItem, &ebox, &dBox);    
  2345.     GetDItem( dtemp, startbox, &sItem, &sbox, &dBox);    
  2346.  
  2347.     *tempspot = 0;
  2348.     if (screens[scrn].TELstop > 0) {
  2349.         sprintf(tempspot,"^%c",screens[scrn].TELstop^64);
  2350.         c2pstr(tempspot);                                    /* BYU LSC */
  2351.         SetIText( ebox , tempspot);                            /* BYU LSC */
  2352.         SelIText( dtemp, stopbox, 0, 32767);
  2353.         }
  2354.     if (screens[scrn].TELgo > 0) {
  2355.         sprintf(tempspot,"^%c",screens[scrn].TELgo^64);
  2356.         c2pstr(tempspot);                                    /* BYU LSC */
  2357.         SetIText( sbox , tempspot);                            /* BYU LSC */
  2358.         SelIText( dtemp, startbox, 0, 32767);
  2359.         }
  2360.     if (screens[scrn].TELip > 0) {
  2361.         sprintf(tempspot,"^%c",screens[scrn].TELip^64);
  2362.         c2pstr(tempspot);                                    /* BYU LSC */
  2363.         SetIText( kbox , tempspot);                            /* BYU LSC */
  2364.         SelIText( dtemp, killbox, 0, 32767);
  2365.         }
  2366.     
  2367.         dItem=0;                                /* initially no hits */
  2368.         while((dItem>3) || (dItem==0)) {        /* While we are in the loop */
  2369.             ModalDialog((ModalFilterProcPtr) modalProc,&dItem); /* and do our duty to the box */
  2370.  
  2371. /*
  2372. *  intermediate check.  If they hit a key, put its number in the box.
  2373. */
  2374.             GetIText( kbox, tempspot);                    /* BYU LSC - Get the string */
  2375.             p2cstr(tempspot);                            /* BYU LSC */
  2376.             if (*tempspot < 32 && *tempspot > 0) {
  2377.                 sprintf(tempspot,"^%c",*tempspot^64);
  2378.                 c2pstr(tempspot);                        /* BYU LSC */
  2379.                 SetIText( kbox , tempspot);                /* BYU LSC */
  2380.                 SelIText( dtemp, killbox, 0, 32767 );
  2381.                 }
  2382.             GetIText( ebox, tempspot);                    /* BYU LSC - Get the string */
  2383.             p2cstr(tempspot);                            /* BYU LSC */
  2384.             if (*tempspot < 32 && *tempspot > 0) {
  2385.                 sprintf(tempspot,"^%c",*tempspot^64);
  2386.                 c2pstr(tempspot);                        /* BYU LSC */
  2387.                 SetIText( ebox , tempspot);                /* BYU LSC */
  2388.                 SelIText( dtemp, stopbox, 0, 32767);
  2389.                 }
  2390.             GetIText( sbox, tempspot);                    /* BYU LSC - Get the string */
  2391.             p2cstr(tempspot);                            /* BYU LSC */
  2392.             if (*tempspot < 32 && *tempspot > 0) {
  2393.                 sprintf(tempspot,"^%c",*tempspot^64);
  2394.                 c2pstr(tempspot);                        /* BYU LSC */
  2395.                 SetIText( sbox , tempspot);                /* BYU LSC */
  2396.                 SelIText( dtemp, startbox, 0, 32767);
  2397.                 }
  2398.                 
  2399.             }
  2400.                 
  2401.     
  2402.         if (dItem==DLOGCancel) {
  2403.             DisposDialog( dtemp);
  2404.             return;
  2405.             }
  2406.             
  2407.         GetIText( kbox, tempspot);            /* BYU LSC - Get the string */
  2408.         p2cstr(tempspot);                    /* BYU LSC */
  2409.         if (*tempspot != '^') 
  2410.             screens[scrn].TELip = -1;
  2411.         else
  2412.             screens[scrn].TELip = toupper(*(tempspot+1)) ^ 64;
  2413.             
  2414.         GetIText( ebox, tempspot);            /* BYU LSC - Get the string */
  2415.         p2cstr(tempspot);                    /* BYU LSC */
  2416.         if (*tempspot != '^') 
  2417.             screens[scrn].TELstop = -1;
  2418.         else
  2419.             screens[scrn].TELstop = toupper(*(tempspot+1)) ^ 64;
  2420.  
  2421.         GetIText( sbox, tempspot);            /* BYU LSC - Get the string */
  2422.         p2cstr(tempspot);                    /* BYU LSC */
  2423.         if (*tempspot != '^') 
  2424.             screens[scrn].TELgo = -1;
  2425.         else
  2426.             screens[scrn].TELgo = toupper(*(tempspot+1)) ^ 64;
  2427.             
  2428.             
  2429.     DisposDialog( dtemp);
  2430.  
  2431.     updateCursor(1);
  2432. }
  2433.  
  2434. /*
  2435.  *    . - preform a command denoted by the arguments.
  2436.  *        mResult - the result of the menu event
  2437.  *        modifiers- modifiers from the menu event
  2438.  */
  2439.  
  2440. void docommand
  2441.   (
  2442.     long mResult,
  2443.     short modifiers
  2444.   )
  2445. {
  2446.     register int i;
  2447.     int theItem, theMenu;
  2448.  
  2449.     theMenu = mResult >> 16;
  2450.     theItem = mResult & 0xffff;
  2451.     switch(theMenu) {
  2452.     case appleMenu:
  2453.         if (theItem==1)                /* About Dialog */
  2454.             applAbout();
  2455.         else
  2456.           {
  2457.             Str255
  2458.                 name;
  2459.             GetItem(myMenus[0], theItem, name);        /* Desk accessory */
  2460.             OpenDeskAcc(name);
  2461.           }
  2462.         break;
  2463.  
  2464.     case fileMenu:
  2465.         switch(theItem) {            
  2466.             
  2467.         case FLopen:
  2468.             setupport(NOFTP);                            /* Open a connection */                
  2469.             break;
  2470.  
  2471.         case FLclose:
  2472.             if ( numwindows<1 ) break;                /* Close a connection */
  2473.             if ( screens[scrn].corpse) {
  2474.                 netclose( screens[scrn].port);
  2475.                 destroyport( scrn);
  2476.                 }
  2477.             else {
  2478.                 if ( !ReallyClose( scrn) ) break;
  2479.                 netclose(screens[scrn].port);
  2480.                 removeport( scrn);
  2481.                 }
  2482.             if (numwindows <1) 
  2483.                 {
  2484.                 DisableItem( myMenus[Conn],0);
  2485.                 DisableItem(myMenus[Conn],COnext);
  2486.                 DrawMenuBar();
  2487.                 }
  2488.             break;
  2489.  
  2490.         case FLload:                                /* Load a set */
  2491.             LoadCONF();
  2492.             break;
  2493.         case FLsave:                                /* Save a set */
  2494.             if (numwindows<1) break;
  2495.             SaveCONF();
  2496.             break;
  2497.         case FLftp:
  2498.             ftpavail=!ftpavail;                        /* Toggle FTP on/off  */
  2499.             if (ftpavail) {
  2500.                 CheckItem(myMenus[Fil], FLftp,TRUE);
  2501.                 Sftpmode(1);
  2502.                 }
  2503.             else {
  2504.                 CheckItem(myMenus[Fil], FLftp,FALSE);
  2505.                 Sftpmode(0);
  2506.                 }
  2507.             break;
  2508.  
  2509.         case FLbin:                                    /* Toggle MacBinary on/off */
  2510.             MacBinary = !MacBinary;
  2511.             if (MacBinary) {
  2512.                 CheckItem(myMenus[Fil], FLbin,TRUE);
  2513.                 }
  2514.             else {
  2515.                 CheckItem(myMenus[Fil], FLbin,FALSE);
  2516.                 }
  2517.             break;
  2518.  
  2519.         case FLlog:                                        /* Toggle FTP window on/off*/
  2520.             ftplogon=!ftplogon;
  2521.             if(ftplogon) {
  2522.                 CheckItem(myMenus[Fil],FLlog,TRUE);
  2523.                 RSshow(ftplog.vs);
  2524.                 SelectWindow(ftplog.wind);
  2525.                 }
  2526.             else {
  2527.                 CheckItem(myMenus[Fil],FLlog,FALSE);
  2528.                 RShide(ftplog.vs);
  2529.                 }
  2530.             break;
  2531.  
  2532.         case FLdir:                                        /* Set the working dir. */
  2533.             wdset();
  2534.             break;
  2535.  
  2536.         case FLprint:                                /* Print Selection (or gr) */
  2537.             if (prRecHdl==0L) {                        /* Make sure print is inited */
  2538.                 PrOpen();
  2539.                 prRecHdl=(THPrint)NewHandle((long)sizeof(TPrint));
  2540.                 PrintDefault(prRecHdl);
  2541.                 }
  2542.             i=RGgetdnum(FrontWindow());
  2543.             if (i>-1)         
  2544.                 printGraph( i);                        /* Print Graphics */
  2545.             else 
  2546.                 if ( (i=RSfindvwind(FrontWindow())) >-1 ) {
  2547.                     Str255 Title;
  2548.  
  2549.                     GetWTitle( FrontWindow(), &Title);        /* BYU LSC */
  2550.                     printText(i, (Str255 *) &Title,scrn);    /* Print Text selection */
  2551.                     }
  2552.             break;
  2553.  
  2554.         case FLpset:                                    /* Set up for printer */
  2555.             if (prRecHdl==0L) {                        /* make sure print is inited */
  2556.                 PrOpen();
  2557.                 prRecHdl=(THPrint)NewHandle((long)sizeof(TPrint));
  2558.                 PrintDefault(prRecHdl);
  2559.                 }
  2560.             PrStlDialog(prRecHdl);                    /* Present the style dlog*/
  2561.             break;
  2562.  
  2563.         case FLquit:
  2564.             if (numwindows>0)
  2565.               {
  2566.                 if (ReallyQuit())
  2567.                   {
  2568.                     serial_shut();                    /* BYU serial - close serial port */
  2569.                     for (i = numwindows - 1; i >= 0; i--)
  2570.                       {
  2571.                         netclose(screens[i].port);
  2572.                         destroyport(i);
  2573.                       } /* for */
  2574.                   }
  2575.                 else
  2576.                     break;
  2577.               } /* if */
  2578.             quit();                                    /* Guess what this does */
  2579.             break;
  2580.  
  2581.         }
  2582.         break;
  2583.  
  2584.     case editMenu:
  2585.         if (!SystemEdit(theItem-1)) {                /* Is this mine? */
  2586.             switch(theItem) {
  2587.             case EDcopy:                            /* Copy */
  2588.                 i = MacRGfindwind(FrontWindow());    /* is ICR window? */
  2589.                 if (i >= 0)
  2590.                     MacRGcopy(FrontWindow());        /* copy the ICR window */
  2591.                 else {
  2592.                     i=RGgetdnum(FrontWindow());
  2593.                     if (i>-1)                        /* Copy Graphics */
  2594.                         copyGraph( i);
  2595.                     else                            /* Copy Text */
  2596.                         if ( (i=RSfindvwind(FrontWindow())) >-1)
  2597.                             copyText( i);
  2598.                 }
  2599.                 break;
  2600.  
  2601.             case EDcopyt:                            /* Copy Table */
  2602.                 /* 
  2603.                 *  tech note #180 trick to get MultiFinder to pay attention 
  2604.                 */
  2605.                 if (!SystemEdit(EDcopy-1)) {        /* tell it we did a copy */
  2606.                     i=RGgetdnum(FrontWindow());
  2607.                     if (i>-1)            /* Copy Graphics */
  2608.                         copyGraph( i);
  2609.                     else                /* Copy Text */
  2610.                         if ( (i=RSfindvwind(FrontWindow())) >-1)
  2611.                             copyTable( i);
  2612.                 }
  2613.                 break;
  2614.  
  2615.             case EDpaste:                            /* Paste */
  2616.                 if (numwindows<1)
  2617.                         break;
  2618.                     else paste();            /* Paste if there is a wind to do to*/
  2619.                 break;
  2620.             case EDmacros:                            /* Set them Macros */
  2621.                 Macros();
  2622.                 break;
  2623.             case EDprefs:                            /* You know what I like! */
  2624.                 PromptPrefs();
  2625.                 break;
  2626.             default:
  2627.                 break;
  2628.             }
  2629.         }
  2630.         break;
  2631.  
  2632.     case connMenu:
  2633.         if (theItem==1)
  2634.             {
  2635.             if (numwindows >1) 
  2636.                 {
  2637.                 SendBehind( FrontWindow(), 0L);
  2638.                 if (FrontWindow() == console.wind || FrontWindow() == ftplog.wind)
  2639.                     SendBehind( FrontWindow(), 0L);
  2640.                 }
  2641.             break;
  2642.             }
  2643.             
  2644.         else
  2645.             {
  2646.             if ((theItem-2)>(numwindows+1)) break;  /* rotten danish */
  2647.             if (screens[ --theItem-2].active!=0) 
  2648.                 {
  2649.                 displayStatus(theItem-2, screens[theItem-1].active);    /* Tell them about it..... */
  2650.                 break;
  2651.                 }
  2652.             else 
  2653.                 {
  2654.                 HiliteWindow(screens[scrn].wind, FALSE);
  2655.                 changeport(scrn,(theItem-2));
  2656.                 if (!(modifiers &  optionKey)) SelectWindow(screens[scrn].wind);
  2657.                     else HiliteWindow(screens[scrn].wind, TRUE);
  2658.                 }
  2659.             }
  2660.         break;
  2661.  
  2662.     case netMenu:
  2663.         switch(theItem) {
  2664.         case NEftp:                                        /* Send FTP command */
  2665.         case NEip:                                        /* Send IP Number */
  2666.             if (numwindows<1) break;
  2667.             {    char tmpout[30];                        /* Basically the same except for */
  2668.                 int tmp[4];                                /* The ftp -n phrase in NEftp */
  2669.  
  2670.                 if (screens[scrn].echo && (screens[scrn].kblen>0)) {
  2671.                     netwrite( screens[scrn].port, screens[scrn].kbbuf,
  2672.                                 screens[scrn].kblen);/* if not empty send buffer */
  2673.                     screens[scrn].kblen=0;
  2674.                     }
  2675.                 if (screens[scrn].connectionType == 1)                    /* BYU 2.4.15 */
  2676.                     for(i=0; i<4; i++) tmp[i]=(int)SLIP_ip_number[i];    /* BYU 2.4.15 */
  2677.                 else                                                    /* BYU 2.4.15 */
  2678.                     for(i=0; i<4; i++) tmp[i]=(int)myipnum[i];            /* BYU 2.4.15 */
  2679.                 if (theItem == NEftp) {
  2680.                     if ((modifiers & shiftKey) != 0)                                                /* BYU mod */
  2681.                         sprintf(tmpout,"ftp %d.%d.%d.%d\015\012",tmp[0],tmp[1],tmp[2],tmp[3]);        /* BYU mod */
  2682.                     else                                                                            /* BYU mod */
  2683.                         sprintf(tmpout,"ftp -n %d.%d.%d.%d\015\012",tmp[0],tmp[1],tmp[2],tmp[3]);    /* BYU mod */
  2684.                     }                                                                                /* BYU mod */
  2685.                 else
  2686.                     sprintf(tmpout,"%d.%d.%d.%d",tmp[0],tmp[1],tmp[2],tmp[3]);
  2687.                 netwrite(screens[scrn].port,tmpout,strlen(tmpout));
  2688.                 if (screens[scrn].echo)
  2689.                     VSwrite(screens[scrn].vs,tmpout, strlen(tmpout));
  2690.             }
  2691.             break;
  2692.  
  2693.         case NEayt:                                /* Send "Are You There?"*/
  2694.             if (numwindows<1) break;
  2695.             netpush(screens[scrn].port);
  2696.             netwrite(screens[scrn].port, "\377\366",2);
  2697.             break;
  2698.  
  2699.         case NEao:                                /* Send "Abort Output"*/
  2700.             if (numwindows<1) break;
  2701.             netpush(screens[scrn].port);
  2702.             netwrite(screens[scrn].port, "\377\365",2);
  2703.             screens[ scrn].timing = 1;                        /* set emulate to TMwait */
  2704.             netwrite(screens[scrn].port, "\377\375\006",3);        /* send TM */
  2705.             break;
  2706.  
  2707.         case NEinter:                                /* Send "Interrupt Process"*/
  2708.             if (numwindows<1) break;
  2709.             netpush(screens[scrn].port);
  2710.             netwrite(screens[scrn].port, "\377\364",2);
  2711.             screens[ scrn].timing = 1;                        /* set emulate to TMwait */
  2712.             netwrite(screens[scrn].port, "\377\375\006",3);        /* send TM */
  2713.             break;
  2714.  
  2715.         case NEec:                                /* Send "Erase Character"*/
  2716.             if (numwindows<1) break;
  2717.             netpush(screens[scrn].port);
  2718.             netwrite(screens[scrn].port, "\377\367",2);
  2719.             break;
  2720.  
  2721.         case NEel:                                /* Send "Erase Line"*/
  2722.             if (numwindows<1) break;
  2723.             netpush(screens[scrn].port);
  2724.             netwrite(screens[scrn].port, "\377\370",2);
  2725.             break;
  2726.             
  2727.         case NEscroll:                            /* Suspend Network */
  2728.             ScrlLock=!ScrlLock;
  2729.             if (ScrlLock) 
  2730.                 CheckItem(myMenus[Net], NEscroll,TRUE);
  2731.             else 
  2732.                 CheckItem(myMenus[Net], NEscroll,FALSE);
  2733.             break;
  2734.  
  2735.         case NEnet:                                /* Show Network Numbers */
  2736.             showNetNumbers();
  2737.             break;
  2738.  
  2739.         case NEconfig:
  2740.             if (userlevel != 0) break;
  2741.             if (EtherNet == -99)                /* drivers are alive version */
  2742.                 driverconf();                    /* just configure default host */
  2743.             else {
  2744.                 if (numwindows > 0) break;
  2745.                 reconfigNetwork(0);
  2746.                 }
  2747.             break;
  2748.  
  2749.         case NEserial:            /* BYU serial */
  2750.             Setmodem();            /* BYU serial */
  2751.             break;                /* BYU serial */
  2752.  
  2753.         case NEalias:            /* NCSA */
  2754.             DoAlias();            /* NCSA */
  2755.             break;                /* NCSA */
  2756.  
  2757.         default:
  2758.             break;
  2759.         }
  2760.         break;
  2761.  
  2762.     case termMenu:
  2763.         switch(theItem) {
  2764.  
  2765.         case EMbs:                                /* Backspace for backspace  */
  2766.             if (numwindows<1) break;
  2767.             CheckItem(myMenus[3], EMbs+screens[scrn].bsdel,FALSE);
  2768.             screens[scrn].bsdel=0;
  2769.             CheckItem(myMenus[3], EMbs+screens[scrn].bsdel,TRUE);
  2770.             break;
  2771.         
  2772.         case EMdel:                                /* Delete for backspace */
  2773.             if (numwindows<1) break;
  2774.             CheckItem(myMenus[3], EMbs+screens[scrn].bsdel,FALSE);
  2775.             screens[scrn].bsdel=1;
  2776.             CheckItem(myMenus[3], EMbs+screens[scrn].bsdel,TRUE);
  2777.             break;
  2778.  
  2779.         case EMecho:                                /* Toggle Local Echo (if poss.) */
  2780.             if (numwindows < 1) break;
  2781.             if (screens[scrn].echo && (screens[scrn].kblen>0)) {
  2782.                 netwrite( screens[scrn].port, screens[scrn].kbbuf,
  2783.                             screens[scrn].kblen);    /* if not empty send buffer */
  2784.                 screens[scrn].kblen=0;
  2785.                 }
  2786.             screens[scrn].echo= !screens[scrn].echo;    /* toggle */
  2787.             if (screens[scrn].echo) {                    /* LOCAL ECHO */
  2788.                 netwrite(screens[scrn].port,"\377\376\001",3);
  2789.                 CheckItem(myMenus[3],EMecho,TRUE);
  2790.                 }
  2791.             else {                                        /* REMOTE ECHO */
  2792.                 netwrite(screens[scrn].port,"\377\375\001",3);
  2793.                 CheckItem(myMenus[3],EMecho,FALSE);
  2794.                 }
  2795.             break;
  2796.             
  2797.         case EMwrap:                                /* wrap mode */
  2798.             if (numwindows < 1) break;
  2799.             if (!screens[scrn].wrap) {                /* is off, turn on */
  2800.                 screens[scrn].wrap = 1;
  2801.                 CheckItem( myMenus[3],EMwrap, TRUE);
  2802.                 VSwrite(screens[scrn].vs, "\033[?7h",5);    /* kick emulator */
  2803.                 }
  2804.             else {
  2805.                 screens[scrn].wrap = 0;
  2806.                 CheckItem( myMenus[3],EMwrap, FALSE);
  2807.                 VSwrite(screens[scrn].vs, "\033[?7l",5);
  2808.                 }
  2809.             break;
  2810.  
  2811.         case EMscroll:                                        /* Scrollback on CLS */
  2812.             if (numwindows<1) break;
  2813.             screens[scrn].ESscroll = !screens[scrn].ESscroll;
  2814.             VSscrolcontrol( screens[scrn].vs, -1, screens[scrn].ESscroll);
  2815.             if (screens[scrn].ESscroll)
  2816.                 CheckItem(myMenus[3],EMscroll, TRUE);
  2817.             else
  2818.                 CheckItem(myMenus[3],EMscroll, FALSE);
  2819.             break;
  2820.             
  2821.         case EMpage:                                    /* TEK page command */
  2822.             if (numwindows<1) break;
  2823.             parse( &screens[scrn],  (unsigned char *) "\033\014",2);    /* BYU LSC */
  2824.             break;
  2825.  
  2826.         case EMclear:                                /* BYU 2.4.8 - Clear on TEK page */
  2827.             if (numwindows<1) break;                        /* BYU 2.4.8 */
  2828.             screens[scrn].ESclear = !screens[scrn].ESclear;    /* BYU 2.4.8 */
  2829.             if (screens[scrn].ESclear)                        /* BYU 2.4.8 */
  2830.                 CheckItem(myMenus[3],EMclear, TRUE);        /* BYU 2.4.8 */
  2831.             else                                            /* BYU 2.4.8 */
  2832.                 CheckItem(myMenus[3],EMclear, FALSE);        /* BYU 2.4.8 */
  2833.             break;                                            /* BYU 2.4.8 */
  2834.  
  2835.         case EMlines:                                    /* set the # of lines */
  2836.             if (numwindows<1) break;
  2837.             LinesPlease( scrn);
  2838.             break;
  2839.             
  2840.         case EMreset:                                    /* Reset Screen */
  2841.             if (numwindows<1) break;
  2842.             VSreset(screens[scrn].vs);                    /* Reset it */
  2843.             screens[scrn].timing=0;
  2844.             screens[scrn].wrap = 0;                        /* turns wrap off */
  2845.             CheckItem( myMenus[3],EMwrap, FALSE);
  2846.             break;
  2847.         case EMjump:                                    /* Jump Scroll */
  2848.             if (numwindows<1) break;
  2849.             FlushNetwork(scrn);                            /* Flush it */
  2850.             break;
  2851.             
  2852.         case EMsetup:                            /* need dialog to enter new key values */
  2853.             setupkeys();
  2854.             break;
  2855.  
  2856.         case EMcolor:                                        /* Set color */
  2857.             if (numwindows<1) break;
  2858.             if (HasColor)
  2859.                 RScprompt(screens[scrn].vs, (int (*)()) modalProc);    /* Color it */
  2860.             break;
  2861.  
  2862.         case EMslip:                            /* BYU 2.4.15 - Switch to SLIP */
  2863.             if (numwindows<1)                    /* BYU 2.4.15 */
  2864.                 break;                            /* BYU 2.4.15 */
  2865.             switchtoslip(screens[scrn].port);    /* BYU 2.4.15 */
  2866.             break;                                /* BYU 2.4.15 */
  2867.  
  2868.         case EMserial:                            /* BYU 2.4.15 - Switch to Serial */
  2869.             if (!slip_connection)                /* BYU 2.4.16 */
  2870.                 break;                            /* BYU 2.4.15 */
  2871.             slip_connection = 0;                /* BYU 2.4.15 */
  2872.             serial_scrn = -1;                    /* BYU 2.4.15 */
  2873.             SLIP_menus();                        /* BYU 2.4.16 */
  2874.             break;                                /* BYU 2.4.15 */
  2875.  
  2876.         case EMcapture:                                            /* BYU 2.4.18 - Capture session to file */
  2877.             if (VSiscapturing(screens[scrn].vs)) {                /* BYU 2.4.18 */
  2878.                 CloseCaptureFile(screens[scrn].vs);                /* BYU 2.4.18 */
  2879.             } else {                                            /* BYU 2.4.18 */
  2880.                 if(!VSopencapture(scrn, screens[scrn].vs))        /* BYU 2.4.18 */
  2881.                     CheckItem(myMenus[Emul], EMcapture,TRUE);    /* BYU 2.4.18 */
  2882.             }                                                    /* BYU 2.4.18 */
  2883.  
  2884.             break;                                                /* BYU 2.4.18 */
  2885.  
  2886. #ifdef NOTANYMORE
  2887.         case EMcommand:                                    /* Switch menus */
  2888.             whichMenus=!whichMenus;
  2889.             switchMenus(whichMenus);
  2890.             break;
  2891. #endif NOTANYMORE
  2892.         default:
  2893.             break;
  2894.         }
  2895.         break;
  2896.     case fontMenu:
  2897.         if (numwindows>0) {
  2898.             RSchangefont( screens[scrn].vs, FontNumber[theItem], 0, 1);
  2899.             CheckFonts();
  2900.             }
  2901.         break;
  2902.     case sizeMenu:
  2903.         if (numwindows>0) {
  2904.             RSchangefont( screens[scrn].vs, -1, FontSize[theItem], 1);
  2905.             CheckFonts();
  2906.             }
  2907.         break;
  2908.     default:
  2909.         break;
  2910.     
  2911.     }
  2912.     HiliteMenu(0);
  2913.   } /* docommand */
  2914.  
  2915. /*
  2916.  *    portsOpen()    - Count the number of ports open. Returns 3 different answers
  2917.  *                  0= no ports at all, 1= at least active, -1= ports/none active.
  2918.  */
  2919.  
  2920. int portsOpen()
  2921. {
  2922.     int pnum;
  2923.  
  2924.     pnum=numwindows-1;
  2925.     if (pnum<0)  return(0);
  2926.     while (pnum>=0) 
  2927.         if (!screens[pnum--].active && !screens[pnum+1].corpse) return(1);
  2928.     return(-1);
  2929. }
  2930.  
  2931. /*
  2932.  *    extractmenu - remove a connection from the menu.
  2933.  */
  2934.  
  2935. void extractmenu
  2936.   (
  2937.     int pnum
  2938.   )
  2939. {
  2940.     DelMenuItem(myMenus[Conn],pnum+3);
  2941.  
  2942.     AdjustMenus();
  2943. }
  2944.  
  2945. /*
  2946.  *    addinmenu - add a connection's name to the menu in position pnum. (name is
  2947.  *        an str255 pointed at by temps).
  2948.  */
  2949.  
  2950. void addinmenu
  2951.   (
  2952.     int pnum,
  2953.     Str255 *temps,
  2954.     char mark
  2955.   )
  2956. {
  2957.     
  2958.     InsMenuItem(myMenus[Conn], temps, pnum+2);        /* BYU LSC - add string to connections menu */
  2959.  
  2960.     SetItemMark( myMenus[Conn], pnum+3, mark);        /* check this with the appropriate mark */
  2961.     AdjustMenus();
  2962. }
  2963.  
  2964. /*
  2965.  *    opnport(scrn) -    Sets the item mark for <scrn> to opening connection 
  2966.  */
  2967.  
  2968. void opnport
  2969.   (
  2970.     int scrn
  2971.   )
  2972. {
  2973.     unsigned char c=0xa5;
  2974.  
  2975.     SetItemMark( myMenus[Conn],scrn+3, c );
  2976. }
  2977.  
  2978. /*
  2979.  *    liveport(scrn) -    Sets the item mark for <scrn> to opened connection 
  2980.  */
  2981.  
  2982. void liveport
  2983.   (
  2984.     int scrn
  2985.   )
  2986. {
  2987.     unsigned char c=0x00;
  2988.  
  2989.     SetItemMark( myMenus[Conn],scrn+3, c);
  2990.     AdjustMenus();
  2991. }
  2992.  
  2993. /*
  2994.  *    RGtoPICT(i)        - Converts the data in TEK window <i> to PICT format.
  2995.  *                      returns the handle to the picture.
  2996.  */
  2997.  
  2998. PicHandle RGtoPICT(i)
  2999. int i;
  3000. {
  3001.     int j;
  3002.     PicHandle tpic;
  3003.     Rect trect;
  3004.  
  3005.     SetRect(&trect,0,0,384,384);
  3006.     j=VGnewwin(3,0);
  3007.     RGMPsize( &trect );
  3008.     VGzcpy( i, j);                /* Love dat zm factr */
  3009.     tpic=OpenPicture(&trect);
  3010.     ClipRect(&trect);
  3011.     
  3012.     VGredraw(i,j);
  3013.     ClosePicture();
  3014.     VGclose(j);
  3015.  
  3016.     return(tpic);
  3017. }
  3018.  
  3019. /*
  3020.  *    printsleep()    - Provide the network keep alive while we are in print
  3021.  *                      mode.  Also set the abort flag if necessary.
  3022.  */
  3023. void printsleep()
  3024. {
  3025.     Stask();                        /* act like the postman */
  3026.     if (userabort()) (*prRecHdl)->prJob.fFromUsr=TRUE;
  3027. }
  3028.  
  3029.  
  3030.  
  3031.  
  3032.  
  3033. /*------------------------------------------------------------------*/
  3034. /* Alias code                                                        */
  3035. /* NCSA, April 1992                                                    */
  3036. /*------------------------------------------------------------------*/
  3037.  
  3038.  
  3039.  
  3040. /* Find out which item is selected */
  3041. short GetSelectedAlias(ListHandle hList,int theNum)
  3042. {
  3043.     short i;
  3044.     Point theCell;
  3045.     
  3046.     for (i=0;i < theNum;i++)
  3047.         {
  3048.         SetPt(&theCell,0,i);
  3049.         if (LGetSelect(0,&theCell,hList))
  3050.             return i;
  3051.         } 
  3052.     return 0;
  3053. }
  3054.  
  3055.  
  3056.  
  3057.  
  3058. /* Get the list of aliases from the resource file "NCSA Prefs."
  3059.     If there is no such list yet, then make one from scratch */
  3060. AliasRez **GetAlias()
  3061. {
  3062.     AliasRez **theResource;
  3063.     AliasRez *pAliasrez, **hAliasrez;
  3064.     int terr;
  3065.         
  3066.     theResource = (AliasRez **)GetResource('alia',1000);
  3067.     if (theResource !=0L) 
  3068.         return theResource;        /* send it */
  3069.     
  3070.     else /* Make a new one from scratch */
  3071.         {
  3072.  
  3073.         hAliasrez = (AliasRez **)NewHandle(sizeof(AliasRez));
  3074.         HLock ((Handle)hAliasrez);
  3075.         
  3076.         pAliasrez = *hAliasrez;
  3077.         pAliasrez->number =0;
  3078.         pAliasrez->aliases[0].name[0] = 0;        /* no data for us */
  3079.         pAliasrez->aliases[0].port = 0;
  3080.         pAliasrez->aliases[0].alias[0] = 0;
  3081.         HUnlock((Handle)hAliasrez);
  3082.         
  3083.  
  3084. /* add this to the resource file, and check for some strange errors */
  3085.  
  3086.         AddResource((Handle)hAliasrez,'alia',1000,"aliases");
  3087.         if ((terr=ResError())!=0) {
  3088.             putln("Error in addresource");
  3089.             }
  3090.         else 
  3091.             {
  3092.             ChangedResource((Handle)hAliasrez);
  3093.             UpdateResFile(HomeResFile((Handle) hAliasrez));
  3094.             }
  3095.         return hAliasrez;
  3096.         }
  3097. }        
  3098.     
  3099.  
  3100. /* called when a record needs to be deleted, and all the records
  3101.     after it have to be bumped up a slot... */
  3102. void DeleteAlias (short theNum, AliasRez **hAlias)
  3103. {
  3104.     short i;
  3105.     AliasRez *pResource;
  3106.     
  3107.     pResource = *hAlias;        /* shut up, Tim */
  3108.     
  3109.     pResource->number--;
  3110.     for (i=theNum;i < pResource->number; i++)
  3111.         {
  3112.         strcpy(pResource->aliases[i].name,pResource->aliases[i+1].name);
  3113.         strcpy(pResource->aliases[i].alias, pResource->aliases[i+1].alias);
  3114.         pResource->aliases[i].port = pResource->aliases[i+1].port;
  3115.         }
  3116. }
  3117.  
  3118.  
  3119.  
  3120. /* this is the main controlling routine.  Called from DoCommand each
  3121.     time the user selects the Alias... menu item.  Get the data from the
  3122.     resource file, and allow the user to add and remove items, in a modal
  3123.     dialog setting.  At the end, save all relevant changes back to the
  3124.     resource file, and then relax until next time*/
  3125. void DoAlias
  3126.   (
  3127.     void
  3128.   )
  3129. {
  3130.     DialogPtr dtemp;
  3131.     short dItem;
  3132.     Rect dBox;
  3133.     Handle     hHost,hPort,hAlias,hList;        /* dialog control handles */
  3134.     AliasRez **theResource,*pResource;        /* alias resource data */
  3135.     short oldSize,numRecords;
  3136.     char junk[64];
  3137.     ListHandle theList;                        /* our List */
  3138.     Rect listBounds;
  3139.     Point    cellSize,theCell;
  3140.     GrafPtr savePort;                        /* Dont hammer the port! */
  3141.     short i;
  3142.     
  3143.     theResource = GetAlias();            /* get the resource */
  3144.     dtemp=GetNewDialog( AliasDLOG, (Ptr) 0L, (WindowPtr) -1L);    /* Bring on the box */
  3145.     GetPort (&savePort);
  3146.     SetPort((GrafPtr)dtemp);
  3147.     UItemAssign( dtemp, kAliasOutline , (int (*)()) OutlineItem);
  3148.  
  3149.         
  3150. /* lets get some initial data */
  3151.     GetDItem( dtemp, kAliasHostItem, &dItem, &hHost, &dBox);
  3152.     GetDItem( dtemp, kAliasPortItem, &dItem, &hPort, &dBox);
  3153.     GetDItem( dtemp, kAliasAliasItem, &dItem, &hAlias, &dBox);
  3154.     GetDItem( dtemp, kAliasList, &dItem, &hList, &dBox);
  3155.  
  3156.     SetRect(&listBounds,0,0,1,0);
  3157.     SetPt(&cellSize,150,20);
  3158.     
  3159.     FrameRect(&dBox);
  3160.     InsetRect(&dBox,1,1); 
  3161.     dBox.right -= 16;
  3162.     
  3163.     theList = LNew(&dBox,&listBounds,cellSize,0,(WindowPtr)dtemp,
  3164.         1,0,0,1);        /* make the new list from scratch */
  3165.  
  3166.     HLock((Handle)theResource);
  3167.     pResource = *theResource;
  3168.  
  3169. /* add all of the saved aliases to the list */
  3170.  
  3171.     for (i=0;i< (**theResource).number;i++)
  3172.         {
  3173.         LAddRow(1,0,theList); 
  3174.         SetPt(&theCell,0,0);
  3175.         LSetCell(pResource->aliases[i].alias,strlen(pResource->aliases[i].alias),
  3176.                 theCell,theList);
  3177.         }
  3178.     HUnlock((Handle)theResource);
  3179.     LSetSelect(1,theCell,theList);
  3180.  
  3181.  
  3182.     SelIText( dtemp, kAliasHostItem, 0, 32767);
  3183.     HLock((Handle)theResource);
  3184.     pResource = *theResource;
  3185.  
  3186.  
  3187. /* this is the main dialog routine.  Keep chugging away until the user
  3188.     hits OK, or Cancel.  Make sure the list is updated each time the
  3189.     user hits inside our list rect */
  3190.  
  3191.     dItem=0;                                /* initially no hits */
  3192.     while((dItem>2 ) || (dItem==0)) {                    /* While we are in the loop */
  3193.         ModalDialog((ModalFilterProcPtr) modalProc,&dItem); /* and do our duty to the box */
  3194.  
  3195.         if (dItem == kAliasAdd)
  3196.             {
  3197.             oldSize = GetHandleSize((Handle)theResource);
  3198.             SetHandleSize((Handle)theResource,oldSize + sizeof(AliasRecord));
  3199.             numRecords = pResource->number++;
  3200.             GetIText(hHost,pResource->aliases[numRecords].name);
  3201.             GetIText(hAlias,pResource->aliases[numRecords].alias);
  3202.             GetIText(hPort,junk);
  3203.             p2cstr(pResource->aliases[numRecords].name);            /* BYU LSC */
  3204.             p2cstr(pResource->aliases[numRecords].alias);            /* BYU LSC */
  3205.             p2cstr(junk);                                            /* BYU LSC */
  3206.             sscanf(junk,"%d",&pResource->aliases[numRecords].port);
  3207.             theCell.h=0;
  3208.             theCell.v = GetSelectedAlias (theList, numRecords-1);
  3209.             LSetSelect(0,theCell, theList);
  3210.             SetPt(&theCell,0,0);
  3211.             
  3212.             LAddRow(1,0,theList); 
  3213.             LSetCell(pResource->aliases[numRecords].alias,strlen(pResource->aliases[numRecords].alias),
  3214.                 theCell,theList);
  3215.             LSetSelect(1,theCell,theList);
  3216.             }
  3217.  
  3218.         if (dItem == kAliasRemove )
  3219.             {
  3220.             numRecords = pResource->number;
  3221.             theCell.v = GetSelectedAlias (theList, numRecords );            
  3222.             LDelRow(1,theCell.v,theList);
  3223.             DeleteAlias(numRecords - theCell.v -1,theResource);
  3224.             SetPt(&theCell,0,0);
  3225.             LSetSelect(1,theCell, theList);
  3226.             oldSize = GetHandleSize((Handle)theResource);
  3227.             SetHandleSize((Handle)theResource,oldSize - sizeof(AliasRecord));
  3228.             } 
  3229.  
  3230.         if (dItem == kAliasList)
  3231.             {
  3232.             Point theMouse;
  3233.             
  3234.             GetMouse(&theMouse);
  3235.             LClick(theMouse,kListMods,theList);
  3236.             theCell = LLastClick(theList);
  3237.             }
  3238.         }
  3239.  
  3240.  
  3241.     HUnlock((Handle)theResource);    /* Now you can munge the heap */
  3242.  
  3243.     if (dItem==kAliasCancel)         /* go away without a trace */
  3244.             {        
  3245.             SetPort(savePort);
  3246.             LDispose(theList);
  3247.             DisposDialog( dtemp);
  3248.             ReleaseResource ((Handle)theResource);
  3249.             return;
  3250.             }
  3251.  
  3252.  
  3253.     if (dItem == kAliasOK)            /* save the changes for next time */
  3254.         {
  3255.         ChangedResource((Handle)theResource);
  3256.         UpdateResFile(HomeResFile((Handle) theResource));
  3257.         }
  3258.  
  3259.  
  3260.     SetPort(savePort);
  3261.     LDispose(theList);
  3262.     DisposDialog( dtemp);
  3263.     ReleaseResource((Handle)theResource);    
  3264. }
  3265.  
  3266.  
  3267.  
  3268.  
  3269.  
  3270. /* given an Alias Name, get all of the data about the host and port.
  3271.     This is called by SetUpPort, and is called whenever the user tries
  3272.     to open any connection.  Just check to see if the name is an alias. */
  3273.  
  3274. int GetDataFromAlias(char *theAlias, AliasRecord *theRecord)
  3275. {
  3276.     AliasRez **hAlias, *pAlias;
  3277.     short i;
  3278.     short found;
  3279.     
  3280.  
  3281.     hAlias = (AliasRez **)GetResource('alia',1000);
  3282.     if (hAlias == 0L) 
  3283.         return -1;
  3284.     
  3285.     HLock((Handle)hAlias);
  3286.     pAlias = *hAlias;
  3287.     
  3288.     found = 0;
  3289.     for (i=0;i < pAlias->number; i++)        /* found it!!  */
  3290.         if (strcmp(theAlias,pAlias->aliases[i].alias) ==0 )
  3291.             {
  3292.             strcpy(theRecord->name,pAlias->aliases[i].name);
  3293.             strcpy(theRecord->alias,pAlias->aliases[i].alias);
  3294.             theRecord->port = pAlias->aliases[i].port;
  3295.             found =1;
  3296.             }
  3297.  
  3298.     HUnlock((Handle)hAlias);
  3299.     ReleaseResource((Handle)hAlias);
  3300.     return found;
  3301. }
  3302.  
  3303.  
  3304.